Delete, Truncate or Drop to clean out a table in MySQL

前端 未结 6 561
野性不改
野性不改 2021-02-07 03:49

I am attempting to clean out a table but not get rid of the actual structure of the table. I have an id column that is auto-incrementing; I don\'t need to keep the

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-07 04:11

    drop table will remove the entire table with data

    delete * from table will remove the data, leaving the autoincrement values alone. it also takes a while if there's a lot of data in the table.

    truncate table will remove the data, reset the autoincrement values (but leave them as autoincrement columns, so it'll just start at 1 and go up from there again), and is very quick.

提交回复
热议问题