|
Sometimes, you may want to delete one or more unused tables from a database.
To do this, you use the DROP TABLE statement as follows:
DROP TABLE [schema_name.]table_name;
|
In this syntax:
- First, specify the name of the schema to which the table belongs.
The schema is optional.
If you skip it, the statement will delete the specified table in the current schema.
- Second, specify the name of the table that you want to drop.
When you use the DROP TABLE statement to delete a table, Db2 performs the following actions:
- Delete all data in the table permanently.
- Delete all columns of the dropped table and the indexes associated with these columns.
- Mark all views that reference to the dropped table as inoperative.
- Also, mark all triggers that depend on the dropped table as inoperative.
- Revoke all privileges on the table and dependent views.
Nesta sintaxe:
- Primeiro, especifique o nome do esquema ao qual a tabela pertence.
O esquema é opcional.
Se você ignorá-lo, a instrução excluirá a tabela especificada no esquema atual.
- Em segundo lugar, especifique o nome da tabela que você deseja descartar.
Quando você usa a instrução DROP TABLE para excluir uma tabela, o Db2 executa as seguintes ações:
- Exclui todos os dados da tabela permanentemente.
- Exclui todas as colunas da tabela eliminada e os índices associados a essas colunas.
- Marque todas as visualizações que fazem referência à tabela eliminada como inoperantes.
- Além disso, marque todos os gatilhos que dependem da tabela eliminada como inoperantes.
- Revogar todos os privilégios na tabela e visualizações dependentes.
Deletes an existing table in the database
Exclui uma tabela existente no banco de dados
The following SQL deletes the table "Shippers":
O seguinte SQL exclui a tabela "Shippers":
|