The 1.SQL statement can be divided into the following 4 categories:
1.1 DDL (data definition Languages) statements that define different data segments, databases, tables, columns, indexes, and so on.
The definition of the database object. The commonly used statement keywords include create, drop, alter and so on.
Create DATABASE Database-name//Create a databaseCREATE TABLE TabName (col1 type1 [notNULL] [primary key],col2 type2 [notNULL],..)//Create a new tableCreate a new table from an existing surface a:create table tab_new like Tab_old (Create a new table with the old table) b:create table tab_new asSelectcol1,col2 tab_old definition only create [unique] index idxname on tabname (col ...)//Create an indexDrop INDEX Idxname//Delete IndexCREATE VIEW viewname asSelectStatement//Create a ViewDrop View ViewName//Delete a viewDrop Database dbname//Deleting a databasedrop table TabName//Delete a new tableAlter table tabname Add column col type//Add a column//Note: Columns cannot be deleted after they are added. DB2 the column plus the data type can not be changed, the only change is to increase the length of the varchar type. Alter table TabName Add primary key (COL)//Add primary KeyAlter table TabName Drop primary key (COL)//Delete primary Key
1.2 DML (Data manipulation Language) statement: Data manipulation statements for adding, deleting, updating, and querying database records, and for checking data integrity.
Common statement keywords include insert, delete, udpate, select, and so on.
1.3 DCL (Data Control Language) statement: A statement that controls the level of permission and access to different data segments directly.
These statements define the database, table, field, user's access rights, and security level. The main statement keywords include GRANT, revoke, and so on.
1.4 DQL (data query Language) statement: A database lookup statement that is used to retrieve information from one or more tables.
SQL Basic Syntax