DROP FOREIGN TABLE (SQL)
Synopsis
DROP FOREIGN TABLE [ IF EXISTS ] table-name [ RESTRICT | CASCADE ]
Arguments
Arguments | Description |
---|---|
IF EXISTS | Optional — Suppresses the error that arises if a foreign table with table-name does not exist. |
table-name | The name of the foreign table to be dropped. This name must be a valid identifier. A foreign table by this name must exist for the command to execute successfully. |
RESTRICT | Optional — Specifies that the foreign table should not be dropped if any SQL objects, such as views, are defined on the foreign table. This option supplies the default behavior. |
CASCADE | Optional — Specifies that all objects defined on the foreign table, such as views, are dropped with the foreign table. |
Description
The DROP FOREIGN TABLE command deletes a foreign table from a foreign server.
By default, this command will only delete a foreign table if no views are associated with it; you may explicitly apply this behavior by specifying the RESTRICT keyword. When the RESTRICT keyword has been implicitly or explicitly specified, attempting to delete a foreign table with associated views generates an SQLCODE -321 error.
When the CASCADE keyword is specified, DROP FOREIGN TABLE will successfully delete the table and any views associated with it.
In order to delete a foreign table, the following conditions must be met:
-
The foreign table must exist on a foreign server in the current namespace. Attempting to delete a non-existent foreign table generates an SQLCODE -30 error. This error is suppressed by epcifying the IF EXISTS keywords.
-
You must have the necessary privileges to delete the foreign table. Attempting to delete a table without the necessary privileges generates an SQLCODE -99 error.
Examples
The following example deletes a foreign table that does not have any objects defined on it.
DROP FOREIGN TABLE Example.MyTable RESTRICT
The following example deletes a foreign table and any views associated with it.
DROP FOREIGN TABLE Example.MyTable CASCADE