MySQL 8.0 Reference Manual Including MySQL NDB Cluster 8.0
TRUNCATE TABLE
is normally
regarded as a DML statement, and so would be expected to be
logged and replicated using row-based format when the binary
logging mode is ROW
or
MIXED
. However this caused issues when
logging or replicating, in STATEMENT
or
MIXED
mode, tables that used transactional
storage engines such as InnoDB
when
the transaction isolation level was READ
COMMITTED
or READ UNCOMMITTED
,
which precludes statement-based logging.
TRUNCATE TABLE
is treated for
purposes of logging and replication as DDL rather than DML so
that it can be logged and replicated as a statement. However,
the effects of the statement as applicable to
InnoDB
and other transactional
tables on replicas still follow the rules described in
Section 15.1.37, “TRUNCATE TABLE Statement” governing such tables. (Bug
#36763)