TRUNCATE TABLE Command

<< Click to Display Table of Contents >>

Navigation:  SQL Reference > SQL Commands >

TRUNCATE TABLE Command

Previous pageReturn to chapter overviewNext page

 

TRUNCATE TABLE allows you to remove all rows from a table.

Syntax

TRUNCATE [ TABLE ] [ MEMORY ] table_name

Description

TRUNCATE quickly removes all rows from a table. It has the same effect as an unqualified DELETE but since it does not actually scan the table it is faster. This is most useful on large tables.

 

MEMORY

If MEMORY keyword is specified before the table_name then an in-memory table will be truncated, not a disk one.

 

table_name

The name of the table to be truncated.

 

Example:

TRUNCATE TABLE developers;

 

Note:

TRUNCATE requires exclusive access to the table whereas DELETE doesn't. So if you'd like to empty table open by another user, you should use DELETE command instead of TRUNCATE.

__________________________
Absolute SQL Reference - 06 February 2021, Niels Knabe