truncate table nowcoder_exam_record;

方法一、truncate

情况表中的记录并重置自增id。

  • [使用]:truncate table
  • [注意]:truncate只能作用于表;truncate会清空表中的所有行,但表结构及其约束、索引等保持不变;truncate会重置表的自增值;使用truncate后会使表和索引所占用的空间会恢复到初始大小。

方法二、drop

删除表的数据和结构之后重新建表。

  • [使用]:drop table if exists nowcoder_exam_record;create table if not exists nowcoder_exam_record...
  • [注意]:drop会删除表的结构及其所依赖的约束、索引等;drop语句将表所占用的空间全释放掉。所以使用之后需要重建表。

不可用delete

delete删除表中的元组并且不会重置表的自增值;delete操作不会减少表或索引所占用的空间;delete并不能删除表的结构,所以不能像drop一样用于删除表的结构之后再重新建表。delete多于用删除部分数据