DROP TABLE Statement in Confluent Cloud for Apache Flink¶
The DROP TABLE statement removes a table definition from Apache Flink® and, depending on the table type, will also delete associated resources like the Kafka topic and schemas in Schema Registry.
Syntax¶
DROP TABLE [IF EXISTS] table_name
Parameters¶
IF EXISTS
- Optional clause that prevents an error if the table does not exist.
table_name
- The name of the table to drop.
Description¶
The DROP TABLE statement behavior varies depending on the table type:
Regular Tables¶
For tables backed by Kafka topics (created using CREATE TABLE or inferred from existing topics):
- Deletes the underlying Kafka topic permanently
- When using TopicNameStrategy (default): - Deletes all versions of the associated schemas from Schema Registry
- When using RecordNameStrategy or TopicRecordNameStrategy: - Deletes the Kafka topic but preserves schemas in Schema Registry
External Tables¶
Note
The AI model inference feature is available for preview. A Preview feature is a Confluent Cloud component that is being introduced to gain early feedback from developers. Preview features can be used for evaluation and non-production testing purposes or to provide feedback to Confluent. The warranty, SLA, and Support Services provisions of your agreement with Confluent do not apply to Preview features. Confluent may discontinue providing preview releases of the Preview features at any time in Confluent’s sole discretion.
For external tables (such as vector databases and lookup tables):
- Removes the table definition from Flink’s metadata
- Does not delete data from the external system
- Examples include vector search tables and federated search tables
Permissions¶
To execute DROP TABLE, you need a RBAC roles that allows you to delete the Kafka topics and/or Schema Registry schema subjects.
Important Considerations¶
- The DROP TABLE operation is not atomic. If either the Kafka topic deletion or schema deletion fails, the operation may partially complete.
- Dropping a table permanently deletes the Kafka topic data.
- Running statements that depend on a dropped table will transition to DEGRADED status.
- It’s recommended to stop dependent statements before dropping a table.
- When using TopicNameStrategy, dropping a table will delete schemas even if they are used by other topics.
Examples¶
Drop a Kafka-backed table:
DROP TABLE my_table;
Drop a table if it exists:
DROP TABLE IF EXISTS my_table;