Syntax
To target a table with multiple column families, set the when creating a changefeed:FAMILY keyword:
You can also use on tables with column families by using the statement with
split_column_families or the FAMILY keyword.FAMILY keyword will ensure the changefeed emits messages for each column family you define with FAMILY in the CREATE CHANGEFEED statement. If you do not specify FAMILY, then the changefeed will emit messages for all the table’s column families.
To specify multiple families on the same table, it is necessary to define the table and family in both instances:
Message format
The response will follow a typical , but with the family name appended to the table name with a., in the format table.family:
+, in the format table+primary.
schema names will include the family name concatenated to the table name.
The primary key columns will appear in the key for all column families, and will also appear in the value only for the families that they are a member of.
For example, if the table office_dogs has a column family primary, containing the primary key and a STRING column, and a secondary column family containing a different STRING column, then you’ll receive two messages for an insert.
split_column_families) will emit the following when there are inserts to the table:
primary column family with 4 in the value ({"id":4,"name":"Toby"}) and the key ("key":[4]). The secondary family doesn’t contain the id column, so the primary key 4 is only in the key and not the value. For an update that only affects data in one column family, the changefeed will send one message for that update relating to the family.
Considerations
- If you create a table without column families and then start a changefeed with the
split_column_familiesoption, it is not possible to add column families. A subsequentALTER TABLEstatement adding a column family to the table will cause the changefeed to fail. - When you do not specify column family names in the
CREATEorALTER TABLEstatement, the family names will default to either of the following:primary: Sinceprimaryis a key word, you’ll receive a syntax error if you runCREATE CHANGEFEED FOR table FAMILY primary. To avoid this syntax error, use double quotes:CREATE CHANGEFEED FOR table FAMILY "primary". You’ll receive output from the changefeed like:table.primary.fam_<zero-indexed family id_<delimited list of columns: For a table that does not include a name for the family:FAMILY (id, name), you’ll receive output from the changefeed containing:table.fam_0_id_name. This references the table, the family ID and the two columns that this column family includes.
- Creating a changefeed with is not supported on tables with more than one column family.
- When you create a changefeed on a table with more than one column family, the changefeed will emit messages per column family in separate streams. As a result, for different column families will arrive at the under separate topics. For more details, refer to Message format.
- Enterprise Changefeeds
- Basic Changefeeds
Create a changefeed on a table with column families
In this example, you’ll set up changefeeds on two tables that have . You’ll use a single-node cluster sending changes to a webhook sink for this example, but you can use any to work with tables that include column families.- If you do not already have one, .
-
Use the command to start a single-node cluster:
-
As the
rootuser, open the : -
Set your organization and license key:
-
Enable the
kv.rangefeed.enabled: -
In a separate terminal window, set up your HTTP server. Clone the test repository:
-
Next make the script executable and then run the server (passing a specific port if preferred, otherwise it will default to
:3000): -
Back in your SQL shell, create a database called
cdc_demo: -
Set the database as the default:
-
Create a table with two column families:
-
Insert some data into the table:
-
Create a second table that also defines column families:
-
Insert some data into
office_plants: -
Create a changefeed on the
office_dogstable targeting one of the column families. Use theFAMILYkeyword in theCREATEstatement:You’ll receive one message for each of the inserts that affects the specified column family:
The ordering of messages is not guaranteed. That is, you may not always receive messages for the same row, or even the same change to the same row, next to each other.
FAMILY keyword across two tables:To create a changefeed specifying two families on one table, ensure that you define the table and family in both instances:
CREATE CHANGEFEED FOR TABLE office_dogs FAMILY employee, TABLE office_dogs FAMILY dogs INTO {sink};-
To create a changefeed that emits messages for all column families in a table, use the option:
You’ll receive output for both of the column families in the
office_dogstable:
You can find details of your changefeed job using . Changefeeds streaming to or will populate the
topics field in the SHOW CHANGEFEED JOBS output.When using the FAMILY keyword, the topics field will display in the format topic.family, e.g., office_dogs.employee,office_dogs.dogs. With the split_column_families option set, topics will show the topic name and a family placeholder topic.{family}, e.g., office_dogs.{family}.-
Update one of the values in the table:
This only affects one column family, which means you’ll receive one message:

