TRUNCATE TABLE

Updated at:
Copy as MD

Removes all rows from a table without logging individual row deletions.

Prerequisites

Before you begin, ensure that you have:

  • The DROP privilege on the target table

Syntax

TRUNCATE [TABLE] tbl_name
ParameterDescription
TABLEOptional keyword. TRUNCATE tbl_name and TRUNCATE TABLE tbl_name are equivalent.
tbl_nameThe name of the table to truncate.

For the full syntax specification, see TRUNCATE TABLE statement.

Example

The following example truncates a table named orders and verifies the result.

-- Check the current row count
SELECT COUNT(*) FROM orders;
-- Result: 1000 rows

-- Truncate the table
TRUNCATE TABLE orders;

-- Verify the table is empty
SELECT COUNT(*) FROM orders;
-- Result: 0 rows

Behavior and limits

BehaviorDescription
PermissionsRequires the DROP privilege on the table. If you lack this privilege, the statement fails.

See also

  • DELETE — Remove specific rows using a WHERE condition.

  • DROP TABLE — Remove the table and its structure entirely.