Remove all data from one table
The simplest form of the TRUNCATE TABLE
statement is as follows:
TRUNCATE TABLE table_name;
Remove all data from table that has foreign key references
To remove data from the main table and all tables that have foreign key references to the main table, you use CASCADE
option as follows:
TRUNCATE TABLE table_name CASCADE;
Update:
BEGIN;
ALTER TABLE table_name DISABLE TRIGGER ALL;
TRUNCATE TABLE table_name;
ALTER TABLE table_name ENABLE TRIGGER ALL;
COMMIT;