blob: bfd9aea5f28a8132437507ac5e3f8e04752e7365 [file] [log] [blame]
---
title: TRUNCATE
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
Empties a table of all rows.
## <a id="topic1__section2"></a>Synopsis
``` pre
TRUNCATE [TABLE] <name> [, ...] [CASCADE | RESTRICT]
```
## <a id="topic1__section3"></a>Description
`TRUNCATE` quickly removes all rows from a table or set of tables.This is most useful on large tables.
## <a id="topic1__section4"></a>Parameters
<dt> \<name\> </dt>
<dd>Required. The name (optionally schema-qualified) of a table to be truncated.</dd>
<dt>CASCADE </dt>
<dd>Since this key word applies to foreign key references (which are not supported in HAWQ) it has no effect.</dd>
<dt>RESTRICT </dt>
<dd>Since this key word applies to foreign key references (which are not supported in HAWQ) it has no effect.</dd>
## <a id="topic1__section5"></a>Notes
Only the owner of a table may `TRUNCATE` it. `TRUNCATE` will not perform the following:
- Run any user-defined `ON DELETE` triggers that might exist for the tables.
**Note:** HAWQ does not support user-defined triggers.
- Truncate any tables that inherit from the named table. Only the named table is truncated, not its child tables.
## <a id="topic1__section6"></a>Examples
Empty the table `films`:
``` sql
TRUNCATE films;
```
## <a id="topic1__section7"></a>Compatibility
There is no `TRUNCATE` command in the SQL standard.
## <a id="topic1__section8"></a>See Also
[DROP TABLE](DROP-TABLE.html)