Your first link (Why is truncate DDL?) is about Oracle, not MySQL. While relevant, different DBMS implement same features differently. In Oracle and SQL Server
TRUNCATE is DDL, not DML.
In MySQL, it matter which version you use:
TRUNCATE TABLE is equivalent to a
DELETE statement that deletes all rows, but there are practical differences under some circumstances.
For an InnoDB table:
If there are no
FOREIGN KEY constraints, InnoDB performs fast truncation by dropping the original table and creating an empty one with the same definition, which is much faster than deleting rows one by one.
When you use this fast truncation technique with the
innodb_file_per_table option enabled, the operating system can reuse the freed disk space. For users of the InnoDB Plugin, the space is reclaimed automatically, as described in Reclaiming Disk Space with
TRUNCATE TABLE. If you do not have the InnoDB Plugin installed, issue the
OPTIMIZE TABLE statement to free the disk space for the table.
If there are any
FOREIGN KEY constraints that reference the table, InnoDB processes
TRUNCATE TABLE by deleting rows one by one, processing the constraints as it proceeds. If the
FOREIGN KEY constraint specifies
DELETE CASCADE, rows from the child (referenced) table are deleted, and the truncated table becomes empty. If the
FOREIGN KEY constraint does not specify
TRUNCATE TABLE statement deletes rows one by one and stops if it encounters a parent row that is referenced by the child, returning this error:
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign
key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1`
FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`))
But for versions 5.5 and later, the documentation says:
TRUNCATE TABLE is similar to a
DELETE statement that deletes all rows, or a sequence of
DROP TABLE and
CREATE TABLE statements. To achieve high performance, it bypasses the DML method of deleting data. Thus, it cannot be rolled back, it does not cause
ON DELETE triggers to fire, and it cannot be performed for InnoDB tables with parent-child foreign key relationships.
TRUNCATE TABLE is similar to
DELETE, it is classified as a DDL statement rather than a DML statement. It differs from
DELETE in the following ways in MySQL 5.5: