Insert three tables:
@d:/del_data.sql;
@d:/hr_cre.sql;
@d:/hr_popul.sql;
select * from employees;
DML for the difference between consultation and modify data record contains the following sql statement:
INSERT: add data to the database
UPDATE: modify data in the database
DELETE: delete data in the database
SELECT: Select (query) data
DDL defines the structure of the database, such as creating, modifying or deleting database objects, include the following sql statement:
CREATE TABLE: Create a database table
ALTER TABLE: change the table structure, add, delete, modify the column length
DROP TABLE: Delete table
CREATE INDEX: index on the table
DROP INDEX: Delete Index
DCL for controlling access to the database, comprising the sql statement
GRANT: grant access
REVOKE: revoke access
COMMIT: to commit the transaction
POLLBACK: Transaction rollback
SAVEPOINT: set a savepoint
LOCK: to lock certain parts of the database
- What are the lookup table columns:
desc employees;
desc employees Name null type -------------- -------- ------------ EMPLOYEE_ID NOT NULL NUMBER(6) FIRST_NAME VARCHAR2(20) LAST_NAME NOT NULL VARCHAR2(25) EMAIL NOT NULL VARCHAR2(25) PHONE_NUMBER VARCHAR2(20) HIRE_DATE NOT NULL DATE JOB_ID NOT NULL VARCHAR2(10) SALARY NUMBER(8,2) COMMISSION_PCT NUMBER(2,2) MANAGER_ID NUMBER(6) DEPARTMENT_ID NUMBER(4)
- Query the specified column sql statement
select employee_id,last_name,email from employees;
EMPLOYEE_ID LAST_NAME EMAIL ----------- ------------------------- ------------------------- 100 King SKING 101 Kochhar NKOCHHAR 102 De Haan LDEHAAN 103 Hunold AHUNOLD 104 Ernst BERNST 107 Lorentz DLORENTZ
. . .
Arithmetic operators are available:
select 7+2 from dual;
7+2 ---------- 9
Date is calculated:
select last_name,salary,12*salary+1000 from employees;
LAST_NAME SALARY 12*SALARY+1000 ------------------------- ---------- -------------- King 24000 289000 Kochhar 17000 205000 De Haan 17000 205000 Hunold 9000 109000
select sysdate,sysdate+1,sysdate-2 from dual;
SYSDATE SYSDATE+1 SYSDATE-2 --------- --------- --------- 21-MAR-20 22-MAR-20 19-MAR-20
Note: null value different from 0; the participation of all null value calculation, the result is empty (null)
- column alias: class name as an alias as can be added from time to increase, you want to be added to the case-insensitive alias ""
SELECT employee_id AS "id", last_name as name, email FROM employees;
to EMAIL to NAME the id - -------- ------------ ------------------------- ------------- 100 at King SKING 101 Kochhar NKOCHHAR 102 the De Haan, Belgium LDEHAAN 103 Hunold AHUNOLD
Connector: The column to column, together with the character column
Expressed ||
It can be used for the synthesis column
select last_name|| '`s job_id is' || job_id as details from employees;
DETAILS ----------------------------------------------- King`s job_id isAD_PRES Kochhar`s job_id isAD_VP The Haan`s job_id isAD_VP Hunold`s job_id isIT_PROG
Note: SQL played in only when using the alias "", others are using ''
- Repeat distinct line deduplication
SELECT DISTINCT
Company FROM Orders;
SQL : | SQL*PLUS: |
A language ANSI Standard Keywords can not be abbreviated Data and definition information table using the control table in the database statements in
|
An environment One of the characteristics of Oracle Keywords can be abbreviated Changing the value of the command data in the database Centralized operation |
FF