SHOWDATABASES;#增加数据库CREATEDATABASEIFNOTEXISTS test CHARACTERSET gbk
#删除数据库DROPDATABASEIFEXISTS test
#更改数据库ALTERDATABASE test CHARACTERSET utf8
#查看数据库SHOWDATABASESSHOWCREATEDATABASE test
SHOWTABLESFROM test
#创建表CREATETABLE employ(id INT,NAME VARCHAR(15))#写上个别名,否则会增加其他列ASSELECT employee_id AS id ,last_name AS NAME FROM atguigudb.`employees`#删除表DROPTABLE employ#删除表TRUNCATETABLE employ#清空表#更改表RENAMETABLE employees TO employ
#查看表SHOWTABLES;SHOWCREATETABLE employ;SELECT*FROM employ
#增加字段ALTERTABLE employ
ADD salary DECIMAL(10,2)#删除字段ALTERTABLE employ
DROPCOLUMN salary#注意,删除字段增加column#更改字段#更改字段名称ALTERTABLE employ
CHANGE id1 id INT#更改字段的其他(类型,位置)ALTERTABLE employ
MODIFY id VARCHAR(15)AFTER`name`#查看字段DESC employ
#DML之增删改INSERTINTO employ
VALUES('lkj',1000)DELETEFROM employ
WHERE NAME='lkj'UPDATE employ
SET id=101WHERE NAME='king'
DELIMITER $
CREATETRIGGER d
BEFORE INSERTON my_employ
FOR EACH ROWBEGINUPDATE employees
SET employee_id=0WHERE employee_id=100;END $
INSERTINTO my_employ
VALUES(1,'a',1,1)