1.constraint FK_keyname foreign key (key name) reference table2(`key`)----数据库级别的外键不建议使用
2.DML
插入表数据:
insert into tablename(key1,key2,..)values(value1,value1,....),(value2,value2,....)----批量插入;
insert into tablename(key2)values(value2);
修改表数据:
update table set key1=value where `id`=1;
update table set key=value,key1=value1 where id between 1 and 3; ----[1,3]
update table set key=value where id>5 and id<10;----5
update table set name='ooo' ,year=current_time where id=1 or name='xxx' ;
删除表数据:
delete from table where id=1;
truncate 表名 ---清空表数据;
delete from 表名 ----删除所有数据,不清除自增;关机重启数据库 ,自增归1;
truncate table 表名 ---清空数据,自增归1;
删除表:drop table 表名