Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

DELETE all data really fast with TRUNCATE TABLE CASCADE

Though it is a rare occurrence, we have had occasions where we need to purge ALL data from a Table. Our preferred is the TRUNCATE TABLE approach because it's orders of magnitude faster than the DELETE FROM construct. You however can't use TRUNCATE TABLE unqualified, if the table you are truncating has foreign key references from other tables. In comes its extended form, the TRUNCATE TABLE .. CASCADE construct which was introduced in PostgreSQL 8.2, which will not only delete all data from the main table, but will CASCADE to all the referenced tables.


Continue reading "DELETE all data really fast with TRUNCATE TABLE CASCADE"


This post first appeared on Postgres OnLine Journal, please read the originial post: here

Share the post

DELETE all data really fast with TRUNCATE TABLE CASCADE

×

Subscribe to Postgres Online Journal

Get updates delivered right to your inbox!

Thank you for your subscription

×