Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion documentation/reference/sql/drop.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ permanently deletes all tables, all materialized views, and their contents on di
### IF EXISTS

An optional `IF EXISTS` clause may be added directly after the `DROP TABLE`
keywords to indicate that the selected table should be dropped if it exists.
keywords to indicate that the selected table should be dropped only if it exists.
Without `IF EXISTS`, QuestDB will throw an error if the table does not exist.

## Description

Expand Down
13 changes: 12 additions & 1 deletion documentation/reference/sql/truncate.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ the table itself.

![Flow chart showing the syntax of the TRUNCATE TABLE keyword](/images/docs/diagrams/truncateTable.svg)

### IF EXISTS

An optional `IF EXISTS` clause may be added directly after the `TRUNCATE TABLE`
keywords to indicate that the selected table should be truncated only if it exists.
Without `IF EXISTS`, QuestDB will throw an error if the table does not exist.

## Notes

This command irremediably deletes the data in the target table. In doubt, make
Expand All @@ -19,9 +25,14 @@ sure you have created [backups](/docs/operations/backup/) of your data.
## Examples

```questdb-sql
TRUNCATE TABLE ratings;
TRUNCATE TABLE trades;
```

This example will not throw an error, even if the table does not exist:

```questdb-sql
TRUNCATE TABLE IF EXISTS trades_non_existent;
```
## See also

To delete both the data and the table structure, use
Expand Down
2 changes: 1 addition & 1 deletion static/images/docs/diagrams/.railroad
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ show
)

truncateTable
::= 'TRUNCATE TABLE' tableName ';'
::= 'TRUNCATE TABLE' ('IF' 'EXISTS')? tableName ';'

explain
::= 'EXPLAIN' statement
Expand Down
26 changes: 16 additions & 10 deletions static/images/docs/diagrams/truncateTable.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.