SQL statements are the language for dealing with databases. SQL statements themselves are not case sensitive, but usually Capitalize keywords and non-keywords diff to increase readability. SELECT SYSDATE FROM dual DDL statement DDL statements are used to add, delete, and modify database objects Database objects: tables, views, indexes, sequences Create table: CREATE TABLE employee( id NUMBER(4), name VARCHAR2(20), gender CHAR(1), birth DATE, salary NUMBER(6,2), job VARCHAR2(30), deptno NUMBER(2) ) View table structure DESC employee_xxxx In the database, no matter what type the field is, The default values are all NULL. When we insert data into a table, some If the field does not have a given value, the field will be Default value is inserted. You can use the DEFAULT keyword when creating a table Defines default values individually for the specified fields. In the database, string literals are used are single quotes, and the string content is case sensitive written delete table: DROP TABLE employee CREATE TABLE employee( id NUMBER(4), name VARCHAR2(20), gender CHAR(1) DEFAULT 'M', birth DATE, salary NUMBER(6,2), job VARCHAR2(30), deptno NUMBER(2) ); Modify table 1: Modify the table name RENAME employee TO myemp DESC myemp 2: Modify the table structure 2.1: Add fields Adding fields to a table can only be added to the table's Finally, you cannot insert between existing fields a field. ALTER TABLE myemp ADD( hiredate DATE DEFAULT SYSDATE ) DESC myemp 2.2: Delete existing fields in the table ALTER TABLE myemp DROP(hiredate) DESC myemp 2.3: Modify existing fields Modify the table structure as far as possible without in the table data time. When there is already data in the table When modifying the field, you should pay attention: try not to modify Field type, the length should not be reduced if modified Because shrinking may result in a Failure due to length conflict ALTER TABLE myemp MODIFY( job VARCHAR2(40) DEFAULT 'CLERK' ) DESC myemp DML statement 1: INSERT statement for inserting data into the table When inserting data, you can not specify the field, if you do not specify This is a full column insert, after VALUES all The values corresponding to the fields are all specified. It is recommended to specify fields to increase readability. INSERT INTO myemp (id, name, job, salary) VALUES (1001, 'rose', 'PROGRAMMER', 5500) SELECT * FROM myemp Insert date is recommended TO_DATE() function for INSERT INTO myemp (id,name,birth,deptno) VALUES (2,'jack', TO_DATE('1992-02-04', 'YYYY-MM-DD'),20) SELECT * FROM myemp 2: Modify the data in the table UPDATE statement WHERE is usually used in UPDATE statements Add filter conditions so that only the conditions will be met If the record is not added, the entire record will be modified. All records in the table are modified! UPDATE myemp SET gender='F',id=1002 WHERE name='jack' 3: delete statement DELETE statement The delete statement also needs to use WHERE, otherwise it is Clear table operation! DELETE FROM myemp WHERE name='rose' SELECT * FROM myemp