DROP statements are used to remove a registered table/view/function from current or specified Catalog.
Flink SQL supports the following DROP statements for now:
DROP TABLE
DROP DATABASE
DROP VIEW
DROP FUNCTION
Run a DROP statement
DROP statements can be executed with the executeSql() method of the TableEnvironment, or executed in SQL CLI. The executeSql() method returns ‘OK’ for a successful DROP operation, otherwise will throw an exception.
The following examples show how to run a DROP statement in TableEnvironment and in SQL CLI.
DROP TABLE
Drop a table with the given table name. If the table to drop does not exist, an exception is thrown.
IF EXISTS
If the table does not exist, nothing happens.
DROP DATABASE
Drop a database with the given database name. If the database to drop does not exist, an exception is thrown.
IF EXISTS
If the database does not exist, nothing happens.
RESTRICT
Dropping a non-empty database triggers an exception. Enabled by default.
CASCADE
Dropping a non-empty database also drops all associated tables and functions.
DROP VIEW
Drop a view that has catalog and database namespaces. If the view to drop does not exist, an exception is thrown.
TEMPORARY
Drop temporary view that has catalog and database namespaces.
IF EXISTS
If the view does not exist, nothing happens.
MAINTAIN DEPENDENCIES
Flink does not maintain dependencies of view by CASCADE/RESTRICT keywords, the current way is producing postpone error message when user tries to use the view under the scenarios like the underlying table of view has been dropped.
DROP FUNCTION
Drop a catalog function that has catalog and database namespaces. If the function to drop does not exist, an exception is thrown.
TEMPORARY
Drop temporary catalog function that has catalog and database namespaces.
TEMPORARY SYSTEM
Drop temporary system function that has no namespace.