-create database database_name; show databases;show tables;
|-create -create table table_name(column_name1 column_type,column_name2 column_type); desc table_name;
|
| -drop table table_name;
DDL--------- |-drop -drop database database_name;
(数据定义语言) |
| -alter table table_name ALTER_SPECIFICATION column_name column_definition [first/after column_name];;
|-alter -alter table table_name rename new_table_name;
|-insert -insert into table_name (field1,field2,field3.....) values (value1,value2,value3....)
| -insert into table_name (field1,field2,field3.....) values (record1_value1,record1_value2,...record1_valuen),
| (record2_value1,record2_value2,...record2_valuen);
DML--------- |-update -update table_name set field1=value1,field2=value2... where condition;
(数据操作语言) | -update table_name1,table_name2 set table_name1.field1=expr1,table_name2.field2=expr2 where condition;
|
|-delete -delete from table_name where condition;
| -delete t1,t2...from t1,t2 where condition;
|
|-select -select * from table_name where condition;
| -select * from table_name where condition order by field desc/asc;
| -select * from table_name limit(offset_start,row_count);
| -select field1,field2 fun_name from table_name /where where_contition/group by fieldn/with rollup/having where_contition;
| -select * from t1 union/union all select t2 union/union...;
|-grant select,insert on database_name.* to ‘user_name‘@‘localhost‘ identified by ‘密码‘
DCL---------|
(数据控制语言) |-revoke select,insert on database_name.* to ‘user_name‘@‘localhost‘;