smrati katiyar smrati katiyar - 1 year ago 86
MySQL Question

truncate table taking very long time, is it normal?

I am using truncate table table_name; on a table with around 1 million rows, but it's been taking too long, running since last 3 hours.

Is it normal? Can you suggest some other way to delete all rows from a table, which could be faster?

Answer Source

Truncate wont work in some cases such as ,

when you have index kind of things and some foreign key constraints

Easy way i suggest is

RENAME TABLE table_name TO t1;

CREATE TABLE table_name LIKE t1;


or you can also use DELETE FROM table_name;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download