Skip to main content

DROP FOREIGN SERVER (SQL)

Drops a foreign server.

Synopsis

DROP [ FOREIGN ] SERVER server-name [ RESTRICT | CASCADE ]

Arguments

Arguments Description
server-name The name of the foreign server to be dropped. This name must be a valid identifier. A foreign server by this name must exist for the command to execute successfully.
RESTRICT Optional — Specifies that the foreign server should be dropped if nothing is defined on it. This option supplies the default behavior.
CASCADE Optional — Specifies that all objects defined within the foreign server, including tables, are dropped with the foreign server.

Description

The DROP FOREIGN SERVER command deletes a foreign server that was configured to host foreign tables.

By default, this command will only drop a foreign server that has no foreign tables defined on 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 server with at least one table defined on it generates an SQLCODE -321 error.

When the CASCADE is specified, DROP FOREIGN SERVER will successfully delete the foreign server and all of the tables defined on it.

In order to delete a foreign table, the following conditions must be met:

  • The foreign server must exist in the current namespace. Attempting to delete a non-existent foreign server generates an SQLCODE -30 error.

  • You must have the necessary privileges to delete the foreign server. Attempting to delete a foreign server without the necessary privileges generates an SQLCODE -99 error.

Examples

The following example drops a foreign server that does not have any tables defined on it.

DROP FOREIGN SERVER EmptyServer RESTRICT

The following example drops a foreign server that has tables defined on it. In the process of dropping the foreign server, the tables associated with it are also dropped.

DROP FOREIGN SERVER FullServer CASCADE

See Also

FeedbackOpens in a new tab