2024-01-07 21:03:24 +03:00
# TRUNCATE TABLE
Removes all rows in a base table.
2024-04-28 19:22:56 +03:00
```
2024-01-07 21:03:24 +03:00
< truncate-table > ::=
TRUNCATE TABLE [ < ship-qualifier > ] < table >
[ < as-of-time > ]
2024-04-28 19:22:56 +03:00
```
2024-01-07 21:03:24 +03:00
2024-01-22 00:50:35 +03:00
### API
2024-04-28 19:22:56 +03:00
```
2024-01-07 21:03:24 +03:00
+$ truncate-table
$:
%truncate-table
table=qualified-object
2024-01-22 00:50:35 +03:00
as-of=(unit as-of)
2024-01-07 21:03:24 +03:00
==
2024-04-28 19:22:56 +03:00
```
2024-01-07 21:03:24 +03:00
2024-01-22 00:50:35 +03:00
### Arguments
2024-01-07 21:03:24 +03:00
**`< table > `**
The target table.
2024-01-22 00:50:35 +03:00
**`< as-of-time > `**
Timestamp of table creation. Defaults to `NOW` (current time). When specified, the timestamp must be greater than both the latest database schema and content timestamps.
### Remarks
2024-01-07 21:03:24 +03:00
The command potentially mutates `<table>` , resulting in a state change of the Obelisk agent.
Tables in the *sys* namespace cannot be truncated.
2024-01-22 00:50:35 +03:00
### Produced Metadata
2024-02-03 07:21:21 +03:00
Row count (when table was populated)
2024-07-22 18:33:07 +03:00
Content timestamp
2024-01-07 21:03:24 +03:00
2024-01-22 00:50:35 +03:00
### Exceptions
2024-01-07 21:03:24 +03:00
2024-08-09 01:25:05 +03:00
state change after query in script
2024-01-22 00:50:35 +03:00
database `<database>` does not exist
2024-08-09 01:25:05 +03:00
namespace %ns1 does not exist
`<table>` as-of data time out of order
`<table>` as-of schema time out of order
table `<table>` does not exist in `<namespace>`
2024-01-07 21:03:24 +03:00
`GRANT` permission on `<table>` violated