Delete, Truncate or Drop MySQL question?

TRUNCATE will reset your auto-increment seed (on InnoDB tables, at least), although you could note its value before truncating and re-set accordingly afterwards using alter table : ALTER TABLE t2 AUTO_INCREMENT = value.

TRUNCATE will reset your auto-increment seed (on InnoDB tables, at least), although you could note its value before truncating and re-set accordingly afterwards using alter table: ALTER TABLE t2 AUTO_INCREMENT = value.

Good point on noting the auto-increment seed! I forgot to mention that – george9170 Apr 8 '10 at 16:19 I see thanks man! – Pete Herbert Penito Apr 8 '10 at 18:12.

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.

Truncate table is what you are looking for 1keydata.com/sql/sqltruncate.html.

Truncate, doesn't ruin the table, merely acts as a reset :).

Drop will do just that....drop the table in question, unless the table is a parent to another table. Delete will remove all the data that meets the condition; if no condition is specified, it'll remove all the data in the table. Truncate is similar to delete; however, it resets the auto_increment counter back to 1 (or the initial starting value).

However, it's better to use truncate over delete because delete removes the data by each row, thus having a performance hit than truncate. However, truncate will not work on InnoDB tables where referential integrity is enforced unless it is turned off before the truncate command is issued. So, relax; unless you issue a drop command on the table, it won't be dropped.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions