Truncate

Empties the contents of a table.

Synopsis

TRUNCATE [ TABLE ] name

Parameters

name

The name of the table you wish to truncate. To truncate a table means to remove all rows from the table.

Results

TRUNCATE

The message returned if the specified table is successfully truncated.

ERROR: Relation 'name' does not exist

The error returned if the specified table name does not exist in the connected database.

Description

Use this command to remove all rows of a specified table. It does not scan through the table before removing data, making it rather helpful when emptying large tables of data. In essence, it is a quicker form of the DELETE command.

Example

This example empties all of the rows in the temp_emp table:

booktown=# TRUNCATE TABLE temp_emp;
TRUNCATE
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.104.153