I. Data definition DDL (data definition Language)
Data-setting language refers to the language defined in the format and form of data, he is the first to be set up when each database is to be established, what is the form of data, the form of a field key, tables and tables of the relationship between the reference and so on, are in the beginning must be planned.
1, build the form:
CREATE TABLE table_name (
COLUMN1 datatype [NOT NULL] [NOT NULL primary key],
COLUMN2 datatype [NOT NULL],
...);
Description
DataType--is the format of the data, as detailed in the table.
Nut null--Can you allow the data to be empty (no data has been filled in yet).
Primary key--is the primary key for this table.
2. Change the form
ALTER TABLE TABLE_NAME
Add Column column_name datatype
Description: Adds a field (without deleting a field's syntax.)
ALTER TABLE TABLE_NAME
Add primary key (column_name)
Description: Change the definition of a table to set a field as the primary key.
ALTER TABLE TABLE_NAME
Drop primary KEY (column_name)
Description: Delete the definition of the primary key.
3, the establishment of the index
CREATE INDEX index_name on table_name (column_name)
Description: Index The field of a table to increase the speed of the query.
4, delete
Drop table_name
Drop Index_name