DEV Community

Cover image for [Easy]: Truncate a table and restart Sequences (Identity and cascade)
vasubabu
vasubabu

Posted on

[Easy]: Truncate a table and restart Sequences (Identity and cascade)

Sometimes you may have to delete or truncate your records in the table for your local or dev testing. Easy way is to do with the below command.

  delete from <table> where <condition> = <value> 

This Works!!!

But above command doesn't restart the sequences i.e; IDENTITY and CASCADE associated with table columns.

 TRUNCATE <table_name> RESTART IDENTITY CASCADE;

References:
Stack Overflow

Top comments (0)