6.4.7 TRUNCATE
Syntax
TRUNCATE TABLE table_name
In 3.23 TRUNCATE TABLE
is mapped to
COMMIT ; DELETE FROM table_name
. See section 6.4.6 DELETE
Syntax.
TRUNCATE TABLE
differs from DELETE FROM ...
in the following ways:
-
Truncate operations drop and re-create the table, which is much faster
than deleting rows one by one.
-
Not transaction-safe; you will get an error if you have an active
transaction or an active table lock.
-
Doesn't return the number of deleted rows.
-
As long as the table definition file `table_name.frm' is
valid, the table can be re-created this way, even if the data or index
files have become corrupted.
TRUNCATE TABLE
is an Oracle SQL extension.
This statement was added in MySQL 3.23.28, although from 3.23.28
to 3.23.32, the keyword TABLE
must be omitted.
Add your own comment.