Syntax
Parameters
WITH options
Notes
CREATE CDC TABLErecords metadata only; ingestion starts withALTER CDC TABLE ... RESUME.- Merge-key columns are implicitly
NOT NULL. - In
readmode, merge-key columns must beBOOLEAN,INTEGER,BIGINT,DATE,TIMESTAMP,TIMESTAMPTZ,NUMERIC, orTEXT(NUMERIConly as a single-column key). Usemerge_mode = 'write'for other key types. - For a stream over a partitioned Postgres source, every source partition-key column must be part of the merge key.
- Column names beginning with
__, andlast_seq, are reserved for CDC bookkeeping. merge_modecannot be changed after creation.- In
readmode, direct DML,TRUNCATE, column-levelALTER TABLE,SET PRIMARY INDEX, and aggregating indexes are rejected; renaming the table is allowed.writetables behave like ordinary tables.
Examples
Mirror a Postgres table
Mirror a MongoDB collection with an inferred schema
Sort the table for analytics instead of by key
ALTER CDC TABLE
Controls the ingest worker of a CDC table:RESUMEbinds the ingest worker to the engine that runs the statement and persists the enabled state, so ingestion resumes automatically after an engine restart. The firstRESUMEbackfills the table from a source snapshot before streaming.SUSPENDstops the worker without a final consolidation. For Postgres sources, the idle replication slot retains WAL on the source while suspended.CASCADEapplies toreadmode and triggers the consolidation that otherwise runs everycascade_interval.
DROP TABLE
DROP TABLE <table_name> drops a CDC table together with its hidden staging storage and stops its ingest worker. Dropping the table does not drop the stream; see DROP STREAM for source-side cleanup.
Related
- CDC tables: semantics, merge modes, monitoring.
- CREATE STREAM: define the change feed.
information_schema.cdc_ingests: ingest state, progress, and errors.