The following are some common types of SQL statements:
DDL: Data definition statements
DML: Data Manipulation language
DQL: Data Query Language
DCL: Data Control Language
One: Data definition language DDL
1.1: General operation of the database, the operation of the database table structure belongs to the data definition language
1.2: The operation is the structure of the database and database table itself, not its contents
1.3: Database and database table additions and deletions to change the difference
Refer to the following code
--View the existing database show databases;--create a database db_test; Create DATABASE db_test;--To view the definition information for this data show CREATE database database_test;--delete the databases Db_testdrop db db_test;-- Create a database database_test, and use it; create databases database_test; Use database_test;--can also switch the database in this way--to see the database in use Select ();--Create a table in database Database_test studentcreate tables Student (--ddl s_id INT PRIMARY key auto_increment COMMENT ' This is the primary key, self-growing ', S_name VARCHAR (all) NOT null COMMENT ' This is the student name, not empty ', S_gender varchar (1) Not NULL COMMENT ' This is student sex non-empty ', s_address VARCHAR (COMMENT ' This is Student address ');--View all existing tables in this database show tables;- -View table Student table Structure desc student;--I want to modify student name Sturename table student to stu;--change the name back rename table Stu to student;-- Select modify information for a column in a table (data type, length, and constraint information) ALTER table student MODIFY s_sex VARCHAR (1) Not null;--modify table structure, add a column to the table s_agealter tables student Add S_age INT COMMENT ' This is the age of the students ';--I want s_age this column behind S_name alter TABLE student MODIFY S_age INT after s_name;--add a column s_major and specify its location ALTER TABLE student ADD s_major VARCHAR (s) COMMENT ' This is the student's professional ' after S_gender;--Delete a column s_addressalter table student DROP column s_address;--I want to change S_gender to S_sex and change the data type to Charalter table student Change S_gender s_sex char;--view MySQL database server and database m has SQL character set (client, server side) show VARIABLES like '%char% ';--View the character set of a table in a database show TABLE STATUS from database_test like '%student% ';--View the character set of the tables column, including all the definition information for the column, similar to desc student;show full COLUMNS from student;-- To modify the character set of the table, be aware that ALTER TABLE student CHARACTER set gbk;--removes the table from the Database drop table student;
Six: SQL statement various types of detailed