Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is TRUNCATE a DML statement?

Can we classify/say that TRUNCATE belongs to/falls under DML statement?

Check here for PostgreSQL TRUNCATE compatibility.

NOTE: TRUNCATE is part of SQL standard ANSI SQL 2008 - F200

like image 309
Gnanam Avatar asked Jul 29 '26 11:07

Gnanam


1 Answers

PostgreSQL

I would say it's a DML statement in PostgreSQL: PostgreSQL has a TRUNCATE trigger but PostgreSQL doesn't have DDL triggers. So it can't be a DDL statement.

It acquires an ACCESS EXCLUSIVE lock on each table it operates on and it's not MVCC-safe but it's transactionsafe and you can do a rollback.

The ability to fire triggers for TRUNCATE is a PostgreSQL extension of the SQL standard.

like image 98
Frank Heikens Avatar answered Aug 01 '26 06:08

Frank Heikens