清空数据库的内容
drop table tb1; #直接删除表 delete from tb1; #清空表的内容 truncate table tb1;清空标的内容,速度快 自增数字会从零开始重新计数
mysql> desc student; +----------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+----------------+ | sid | int(11) | NO | PRI | NULL | auto_increment | | sname | varchar(25) | YES | | NULL | | | gender | varchar(2) | YES | | NULL | | | class_id | int(11) | YES | | NULL | | +----------+-------------+------+-----+---------+----------------+ 4 rows in set (0.01 sec) mysql> desc class; +---------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------+-------------+------+-----+---------+----------------+ | cid | int(11) | NO | PRI | NULL | auto_increment | | caption | varchar(25) | YES | | NULL | | +---------+-------------+------+-----+---------+----------------+ 2 rows in set (0.01 sec) mysql> alter table student add constraint fk_stu_cls foreign key student(class_id) references class(cid); Query OK, 0 rows affected (0.38 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql>
277
https://www.cnblogs.com/wupeiqi/articles/5713315.html
https://www.cnblogs.com/wupeiqi/articles/5729934.html