Command Prompt, Inc.
TRUNCATE

TRUNCATE

Name

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

Powered by Mammoth PostgreSQL
Copyright © 2000-2007 Command Prompt, Inc. All Rights Reserved. All trademarks property of their respective owners.