DROP
Remove a table you created, with its registration, in one statement.
Syntax
Write DROP and the table's name. A name may be written plainly or in quotes.
DROP table
DROP "table"
A comma separated list, DROP table_a, table_b, drops each table named.
Parameters and arguments
tableThe table to remove, as a name or a quoted name. The name is read as lower case. It must be a table your account may write that permits deletion
Required: Yes
Name as many tables as you need, separated by commas.
Examples
Remove a table your account created.
Return type and behaviour
DROP answers that it succeeded and returns no rows. The table, the registration of its columns and the registration of the table are removed.
Errors and exceptions
| Error | What happened | How to recover |
|---|---|---|
HTQL-3004 The table is protected and cannot be deleted | The table is a platform or product table, or its name matches no registered table, so it is treated as not deletable | Choose a table your account may write, and check the name |
HTQL-3002 Unauthorized access | The caller lacks the Delete permission on the table | Ask a role that holds it |
HTQL-6001 DROP: table not found | The table is registered but is no longer in the database | Check the name |
HTQL-6001 Refused: … | The protected routine refused the name or the schema | Use a table your account may write |
Placement and context
DROP is a statement of its own, and it may also be a step in the body of a FOR loop, where it runs for each row the loop visits. A table can be dropped once, so write DROP outside a loop.
Limitations
- DROP removes the table and its records. It cannot be undone.
- A table that is not registered as one your account may write, or that does not permit deletion, is refused.
Permissions and security
DROP runs as the caller. The table must be registered as one that permits deletion, which is true of the tables your account created and its link collections, and not of platform tables. The caller also needs the Delete permission on the table.
Best practices
- Use TRUNCATE to empty a table you want to keep.
- Check what the table holds with a read before you drop it.
- Name every table of a retirement in one DROP, so they go together.