DROP Statements

    Flink SQL supports the following DROP statements for now:

    • DROP TABLE
    • DROP DATABASE
    • DROP FUNCTION

    DROP statements can be executed with the method of the TableEnvironment, or executed in SQL CLI. The sqlUpdate() method returns nothing 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.

    1. val settings = EnvironmentSettings.newInstance()...
    2. val tableEnv = TableEnvironment.create(settings)
    3. tableEnv.sqlUpdate("CREATE TABLE Orders (`user` BIGINT, product STRING, amount INT) WITH (...)");
    4. val tables = tableEnv.listTable()
    5. // drop "Orders" table from catalog
    6. tableEnv.sqlUpdate("DROP TABLE Orders")
    7. // an empty string array
    8. val tables = tableEnv.listTable()
    1. [INFO] Table has been created.
    2. Flink SQL> SHOW TABLES;
    3. Orders
    4. Flink SQL> DROP TABLE Orders;
    5. [INFO] Table has been removed.
    6. Flink SQL> SHOW TABLES;
    7. [INFO] Result was empty.

    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.

      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.

      TEMPORARY

      Drop temporary catalog function that has catalog and database namespaces.

      TEMPORARY SYSTEM

      Drop temporary system function that has no namespace.

      IF EXISTS

      If the function doesn’t exists, nothing happens.