![]() ![]() After truncation, the table will appear empty to concurrent transactions, if they are using a snapshot taken before the truncation occurred. The triggers will fire in the order that the tables are to be processed (first those listed in the command, and then any that were added due to cascading). If ON TRUNCATE triggers are defined for any of the tables, then all BEFORE TRUNCATE triggers are fired before any truncation happens, and all AFTER TRUNCATE triggers are fired after the last truncation is performed and any sequences are reset. TRUNCATE will not fire any ON DELETE triggers that might exist for the tables. The CASCADE option can be used to automatically include all dependent tables - but be very careful when using this option, or else you might lose data you did not intend to! Note in particular that when the table to be truncated is a partition, siblings partitions are left untouched, but cascading occurs to all referencing tables and all their partitions with no distinction. ![]() Checking validity in such cases would require table scans, and the whole point is not to do one. TRUNCATE cannot be used on a table that has foreign-key references from other tables, unless all such tables are also truncated in the same command. If concurrent access to a table is required, then the DELETE command should be used instead. ![]() When RESTART IDENTITY is specified, any sequences that are to be restarted are likewise locked exclusively. TRUNCATE acquires an ACCESS EXCLUSIVE lock on each table it operates on, which blocks all other concurrent operations on the table. You must have the TRUNCATE privilege on a table to truncate it. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |