CREATE CHANGEFEED creates a new changefeed, which targets an allowlist of tables called “watched rows”. Every change to a watched row is emitted as a record in a configurable format (such as JSON, Avro, CSV, Parquet, or protobuf) to a or directly to the SQL session.
When a changefeed emits messages to a sink, it works as a . You can create, pause, resume, , or cancel a changefeed job.
To get started with changefeeds, refer to the page for important usage considerations. For details on how changefeeds emit messages, refer to the page.
The examples on this page provide the foundational syntax of the CREATE CHANGEFEED statement. For examples on more specific use cases with changefeeds, refer to the following pages:
Required privileges
As of v25.1, viewing and managing a changefeed job by users with the
CHANGEFEED privilege is deprecated. This functionality of the CHANGEFEED privilege will be removed in a future release.We recommend transitioning users that need to view and manage running changefeed jobs to that own the or them the VIEWJOB or CONTROLJOB privilege. For more details, refer to View and manage changefeed jobs.Privilege model
The following summarizes the operations users can run depending on whether the assigned privileges are at the job or table level:| Granted privileges | Usage |
|---|---|
CHANGEFEED | Create changefeeds on tables. For details, refer to CHANGEFEED privilege. Deprecated: View and manage changefeed jobs on tables. Instead, transition users that need to view and manage running changefeed jobs to that own the or them the VIEWJOB or CONTROLJOB privilege. For more details, refer to View and manage changefeed jobs. |
CHANGEFEED + on external connection | Create changefeeds on tables to an external connection URI. For details, refer to CHANGEFEED privilege. Deprecated: View and manage changefeed jobs on tables. Instead, transition users that need to view and manage running changefeed jobs to that own the or them the VIEWJOB or CONTROLJOB privilege. For more details, refer to View and manage changefeed jobs. Note: If you need to manage access to changefeed sink URIs, set the changefeed.permissions.require\_external\_connection\_sink.enabled=true cluster setting. This will mean that users with these privileges can only create changefeeds on external connections. |
| Job ownership | and manage changefeed jobs (, , and ). For details, refer to View and manage changefeed jobs. |
CONTROLJOB | Manage changefeed jobs (, , and ). For details, refer to View and manage changefeed jobs. |
VIEWJOB | changefeed jobs. For details, refer to View and manage changefeed jobs. |
SELECT | Create a sinkless changefeed that emits messages to a SQL client. |
DeprecatedCONTROLCHANGEFEED role option + SELECT | Create changefeeds on tables. Users with the CONTROLCHANGEFEED role option must have SELECT on each table, even if they are also granted the CHANGEFEED privilege. The CONTROLCHANGEFEED role option will be removed in a future release. We recommend using the system-level privileges CHANGEFEED and CONTROLJOB/ VIEWJOB for fine-grained access control. |
admin | Create, view, and manage changefeed jobs. |
CHANGEFEED privilege
Viewing and managing changefeed jobs with the
CHANGEFEED privilege is deprecated as of v25.1. Instead, transition users that need to view and manage running changefeed jobs to that own the or them the VIEWJOB or CONTROLJOB privilege. For more details, refer to View and manage changefeed jobs.CHANGEFEED privilege to allow them to create changefeeds on a specific table:
CHANGEFEED privilege on a set of tables, they can create changefeeds on the target tables even if the user does not have the or the SELECT privilege on the tables.
These users will be able to create changefeeds, but they will not be able to run a SELECT query on that data directly. However, they could still read this data indirectly if they have read access to the .
You can add CHANGEFEED to the user or role’s with :
changefeed.permissions.require_external_connection_sink.enabled cluster setting. When you enable this setting, users with the on a set of tables can only create changefeeds into .
View and manage changefeed jobs
Users can and manage changefeed jobs when one of the following are met:- Job ownership: They own the job, or are a member of a role that owns a job.
- Global privileges: They are assigned .
Synopsis
Parameters
| Parameter | Description |
|---|---|
table\_name | The name of the table (or tables in a comma separated list) to create a changefeed for. Note: Before creating a changefeed, consider the number of changefeeds versus the number of tables to include in a single changefeed. Each scenario can have an impact on total memory usage or changefeed performance. Refer to for more detail. |
sink | The location of the configurable sink. The scheme of the URI indicates the type. For more information, refer to Sink URI. Note: If you create a changefeed without a sink, your changefeed will run like a sending messages to the SQL client. For more detail, refer to the page. |
option / value | For a list of available options and their values, refer to Options. |
CDC query parameters
Change data capture queries allow you to define the change data emitted to your sink when you create a changefeed. See the page for detail on the functionality, syntax, and use cases for changefeeds created with queries.| Parameter | Description |
|---|---|
sink | The location of the configurable sink. The scheme of the URI indicates the type. For more information, see Sink URI. |
option / value | For a list of available options and their values, see Options. |
target\_list | The columns to emit data from. |
changefeed\_target\_expr | The target table for the changefeed. |
opt\_where\_clause | An optional WHERE clause to apply filters to the table. |
Sink URI
To form the URI for each sink:| URI Component | Description |
|---|---|
scheme | The type of sink, e.g., , . |
host | The sink’s hostname or IP address. |
port | The sink’s port. |
query\_parameters | The sink’s query parameters. |
- (in Preview)
- / HTTP
Query parameters
Parameters should always be URI-encoded before they are included the changefeed’s URI, as they often contain special characters. Use Javascript’s encodeURIComponent function or Go language’s url.QueryEscape function to URI-encode the parameters. Other languages provide similar functions to URI-encode special characters.
| Parameter | Sink Type | Type | Description |
|---|---|---|---|
ASSUME\_ROLE | , , | Pass the ARN of the role to assume. Use in combination with AUTH=implicit or specified. external\_id: Use as a value to ASSUME\_ROLE to specify the external ID for third-party access to your S3 bucket. | |
AUTH | , , , | The authentication parameter can define either specified (default) or implicit authentication. To use specified authentication, pass your Service Account credentials with the URI. To use implicit authentication, configure these credentials via an environment variable. Refer to the page for examples of each of these. | |
api\_key | The API key created for the cluster in Confluent Cloud. | ||
api\_secret | The API key’s secret generated in Confluent Cloud. Note: This must be URL-encoded before passing into the connection string. | ||
ca\_cert | , , Confluent schema registry | The base64-encoded ca\_cert file. Specify ca\_cert for a Kafka sink, webhook sink, and/or a Confluent schema registry. For usage with a Kafka sink, see . It’s necessary to state https in the schema registry’s address when passing ca\_cert: confluent\_schema\_registry='https://schema\_registry:8081?ca\_cert=LS0tLS1CRUdJTiBDRVJUSUZ' See confluent\_schema\_registry for more detail on using this option. Note: To encode your ca.cert, run base64 -w 0 ca.cert. | |
client\_cert | , , Confluent schema registry | The base64-encoded Privacy Enhanced Mail (PEM) certificate. This is used with client\_key. | |
client\_key | , , Confluent schema registry | The base64-encoded private key for the PEM certificate. This is used with client\_cert. Note: Client keys are often encrypted. You will receive an error if you pass an encrypted client key in your changefeed statement. To decrypt the client key, run: openssl rsa -in key.pem -out key.decrypt.pem -passin pass:{PASSWORD}. Once decrypted, be sure to update your changefeed statement to use the new key.decrypt.pem file instead. | |
file\_size | The file will be flushed (i.e., written to the sink) when it exceeds the specified file size. This can be used with the WITH resolved option, which flushes on a specified cadence. When you change or increase file\_size, ensure that you adjust the changefeed.memory.per\_changefeed\_limit, which has a default of 512MiB. Buffering messages can quickly reach this limit if you have increased the file size. Refer to for more detail. Default:16MB | ||
insecure\_tls\_skip\_verify | , | If true, disable client-side validation of responses. Note that a CA certificate is still required; this parameter means that the client will not verify the certificate. Warning: Use this query parameter with caution, as it creates MITM vulnerabilities unless combined with another method of authentication. Default:false | |
partition_format | Specify how changefeed file paths are partitioned in cloud storage sinks. Use partition_format with the following values:
CREATE CHANGEFEED FOR TABLE users INTO 'gs://...?AUTH...&partition_format=hourly' Default: daily | ||
S3\_STORAGE\_CLASS | Specify the Amazon S3 storage class for files created by the changefeed. See Create a changefeed with an S3 storage class for the available classes and an example. Default:STANDARD | ||
sasl\_aws\_iam\_role\_arn | The ARN for the IAM role that has the permissions to create a topic and send data to the topic. For more details on setting up an Amazon MSK cluster with an IAM role, refer to the AWS documentation. | ||
sasl\_aws\_iam\_session\_name | The user-specified string that identifies the session in AWS. | ||
sasl\_aws\_region | The region of the Amazon MSK cluster. | ||
sasl\_client\_id | Client ID for OAuth authentication from a third-party provider. This parameter is only applicable with sasl\_mechanism=OAUTHBEARER. | ||
sasl\_client\_secret | Client secret for OAuth authentication from a third-party provider. This parameter is only applicable with sasl\_mechanism=OAUTHBEARER. Note: You must base64 encode this value when passing it in as part of a sink URI. | ||
sasl\_enabled | , , , | If true, set the authentication protocol with the sasl\_mechanism parameter. You must have tls\_enabled set to true to use SASL. For Confluent Cloud and Azure Event Hubs sinks, this is set to true by default. Default:false | |
sasl\_grant\_type | Override the default OAuth client credentials grant type for other implementations. This parameter is only applicable with sasl\_mechanism=OAUTHBEARER. | ||
sasl\_handshake | , , | For Confluent Cloud and Azure Event Hubs sinks, this is set to true by default. | |
sasl\_mechanism | , , , | Can be set to OAUTHBEARER, SCRAM-SHA-256, SCRAM-SHA-512, or PLAIN. A sasl\_user and sasl\_password are required for PLAIN and SCRAM authentication. For Amazon MSK clusters, set to . sasl\_aws\_iam\_role\_arn, sasl\_aws\_iam\_session\_name, and sasl\_aws\_region are also required in the sink uri. Refer to the tutorial for detail setting up OAuth using Okta. For Confluent Cloud and Azure Event Hubs sinks, sasl\_mechanism=PLAIN is required but set automatically by CockroachDB. Default:PLAIN | |
sasl\_scopes | A list of scopes that the OAuth token should have access for. This parameter is only applicable with sasl\_mechanism=OAUTHBEARER. | ||
sasl\_token\_url | Client token URL for OAuth authentication from a third-party provider. Note: You must URL encode this value before passing in a URI. This parameter is only applicable with sasl\_mechanism=OAUTHBEARER. | ||
sasl\_user | , | Your SASL username. | |
sasl\_password | , | Your SASL password. Note: Passwords should be URL encoded since the value can contain characters that would cause authentication to fail. | |
shared\_access\_key | The URL-encoded key for your Event Hub shared access policy. | ||
shared\_access\_key\_name | The name of your Event Hub shared access policy. | ||
tls\_enabled | , , | If true, enable Transport Layer Security (TLS) on the connection to Kafka. This can be used with a ca\_cert (see below). For Confluent Cloud and Azure Event Hubs sinks, this is set to true by default. Default:false | |
topic\_name | , , , | Allows arbitrary topic naming for Kafka and GC Pub/Sub topics. See the or for detail on supported characters etc. For example, CREATE CHANGEFEED FOR foo,bar INTO 'kafka://sink?topic\_name=all' will emit all records to a topic named all. Note that schemas will still be registered separately. When using Kafka, this parameter can be combined with the topic\_prefix parameter (this is not supported for GC Pub/Sub). Default: table name. | |
topic\_prefix | , , | Adds a prefix to all topic names. For example, CREATE CHANGEFEED FOR TABLE foo INTO 'kafka://...?topic\_prefix=bar\_' would emit rows under the topic bar\_foo instead of foo. |
Options
| Option | Value | Description | |
|---|---|---|---|
avro\_schema\_prefix | Schema prefix name | Provide a namespace for the schema of a table in addition to the default, the table name. This allows multiple databases or clusters to share the same schema registry when the same table name is present in multiple databases. Example: CREATE CHANGEFEED FOR foo WITH format=avro, confluent\_schema\_registry='registry\_url', avro\_schema\_prefix='super' will register subjects as superfoo-key and superfoo-value with the namespace super. | |
compression | gzip, zstd | Compress changefeed data files written to: | |
confluent\_schema\_registry | Schema Registry address | The Schema Registry address is required to use avro. Use the timeout={duration} query parameter (duration string) in your Confluent Schema Registry URI to change the default timeout for contacting the schema registry. By default, the timeout is 30 seconds. To connect to Confluent Cloud, use the following URL structure: 'https://{API\_KEY\_ID}:{API\_SECRET\_URL\_ENCODED}@{CONFLUENT\_REGISTRY\_URL}:443'. See the tutorial for further detail. Use the changefeed.schema\_registry.retry\_count metric to measure the number of request retries performed when sending requests to the schema registry. For more detail on monitoring changefeeds, refer to . | |
cursor | Emit any changes after the given timestamp. cursor does not output the current state of the table first. When cursor is not specified, the changefeed starts by doing an initial scan of all the watched rows and emits the current value, then moves to emitting any changes that happen after the scan. The changefeed will encounter an error if you specify a timestamp that is before the configured garbage collection window for the target table. (Refer to .) With default garbage collection settings, this means you cannot create a changefeed that starts more than in the past. You can use cursor to start-a-new-changefeed-where-a-previous-changefeed-ended. Example: cursor='1536242855577149065.0000000000' | ||
diff | N/A | Publish a with each message, which includes the value of the row before the update was applied. Changefeeds must use the diff option with the default wrapped envelope or the enriched envelope to emit the before field. | |
encode\_json\_value\_null\_as\_object | N/A | Emit JSON NULL values as {"\_\_crdb\_json\_null\_\_": true} to distinguish these values from SQL NULL values. Refer to the page for an example. Note: When this option is enabled, if the changefeed encounters the literal value {"\_\_crdb\_json\_null\_\_": true} in JSON, it will have the same representation as a JSON NULL value and a warning will be printed to the . | |
end\_time | Indicate the timestamp up to which the changefeed will emit all events and then complete with a successful status. Provide a future timestamp to end\_time in number of nanoseconds since the Unix epoch. For example, end\_time="1655402400000000000". You cannot use end\_time and initial\_scan = 'only' simultaneously. | ||
envelope | wrapped / enriched / bare / key\_only / row | wrapped the default envelope structure for changefeed messages containing an array of the primary key, a top-level field for the type of message, and the current state of the row (or null for deleted rows). Refer to the page for more detail on each envelope. Default: envelope=wrapped. Default for : envelope=bare. | |
execution\_locality | Key-value pairs | Restricts the execution of a changefeed to nodes that match the defined locality filter requirements, e.g., WITH execution\_locality = 'region=us-west-1a,cloud=aws'. See for usage and reference detail. | |
extra\_headers | Specifies extra headers for and . Use this option to add headers to all messages sent to the sink. Example: CREATE CHANGEFEED FOR foo WITH extra\_headers='{"x-api-key": "xxx", "some-other-header": "yyy"}' | ||
format | json / avro / csv / parquet / protobuf | Format of the emitted message. avro: For mappings of CockroachDB types to Avro types, and detail on . Note:confluent\_schema\_registry is required with format=avro. csv: You cannot combine format=csv with the diff or resolved options. Changefeeds use the same CSV format as the statement. Refer to for details using these options to create a changefeed as an alternative to EXPORT. Note:initial\_scan = 'only' is required with format=csv. parquet: is the only supported sink. The topic\_in\_value option is not compatible with parquet format. protobuf: and are the only supported sinks. The headers\_json\_column\_name option is not compatible with protobuf format. Default: format=json. | |
full\_table\_name | N/A | Use fully qualified table name in topics, subjects, schemas, and record output instead of the default table name. This can prevent unintended behavior when the same table name is present in multiple databases. Note: This option cannot modify existing table names used as topics, subjects, etc., as part of an statement. To modify a topic, subject, etc., to use a fully qualified table name, create a new changefeed with this option. Example: CREATE CHANGEFEED FOR foo... WITH full\_table\_name will create the topic name defaultdb.public.foo instead of foo. | |
gc\_protect\_expires\_after | Duration string | Automatically expires protected timestamp records that are older than the defined duration. In the case where a changefeed job remains paused, gc\_protect\_expires\_after will trigger the underlying protected timestamp record to expire and cancel the changefeed job to prevent accumulation of protected data. Refer to for more detail on protecting changefeed data. | |
headers\_json\_column\_name | Specify a column that the changefeed emits as Kafka headers, separate from the message payload, for each row’s change event. headers\_json\_column\_name is supported for Kafka sinks. For more details, refer to . Note:headers\_json\_column\_name is not compatible with changefeeds running in protobuf format. | ||
ignore\_disable\_changefeed\_replication | When set to true, the changefeed will emit events even if CDC filtering for TTL jobs is configured using the disable\_changefeed\_replication, sql.ttl.changefeed\_replication.disabled, or the ttl\_disable\_changefeed\_replication. Refer to Filter changefeeds for tables using TTL for usage details. | ||
initial\_scan | yes/no/only | Control whether or not an initial scan will occur at the start time of a changefeed. Only one initial\_scan option (yes, no, or only) can be used. If none of these are set, an initial scan will occur if there is no cursor, and will not occur if there is one. This preserves the behavior from previous releases. With initial\_scan = 'only' set, the changefeed job will end with a successful status (succeeded) after the initial scan completes. You cannot specify yes, no, only simultaneously. If used in conjunction with cursor, an initial scan will be performed at the cursor timestamp. If no cursor is specified, the initial scan is performed at now(). Although the syntax from previous versions is still supported, you cannot combine the previous and current syntax. Default: initial\_scan = 'yes' | |
kafka\_sink\_config | Set fields to configure the required level of message acknowledgement from the Kafka server, the version of the server, and batching parameters for Kafka sinks. Set the message file compression type. See for more detail on configuring all the available fields for this option. Example: CREATE CHANGEFEED FOR table INTO 'kafka://localhost:9092' WITH kafka\_sink\_config='{"Flush": {"MaxMessages": 1, "Frequency": "1s"}, "RequiredAcks": "ONE"}' | ||
key\_column | 'column' | Override the key used in . This changes the key hashed to determine downstream partitions. In sinks that support partitioning by message, CockroachDB uses the 32-bit FNV-1a hashing algorithm to determine which partition to send to. Note:key\_column does not preserve ordering of messages from CockroachDB to the downstream sink, therefore you must also include the unordered option in your changefeed creation statement. It does not affect per-key or the output of key\_in\_value. See the Define a key to determine the changefeed sink partition example. | |
key\_in\_value | N/A | Add a primary key array to the emitted message. This makes the of a deleted row recoverable in sinks where each message has a value but not a key (most have a key and value in each message). key\_in\_value is automatically used for , , and . | |
lagging\_ranges\_threshold | Duration string | Set a duration from the present that determines the length of time a range is considered to be lagging behind, which will then track in the metric. Note that ranges undergoing an initial scan for longer than the threshold duration are considered to be lagging. Starting a changefeed with an initial scan on a large table will likely increment the metric for each range in the table. As ranges complete the initial scan, the number of ranges lagging behind will decrease. Default:3m | |
lagging\_ranges\_polling\_interval | Duration string | Set the interval rate for when lagging ranges are checked and the lagging\_ranges metric is updated. Polling adds latency to the lagging\_ranges metric being updated. For example, if a range falls behind by 3 minutes, the metric may not update until an additional minute afterward. Default:1m | |
metrics\_label | Define a metrics label to which the metrics for one or multiple changefeeds increment. All changefeeds also have their metrics aggregated. The maximum length of a label is 128 bytes. There is a limit of 1024 unique labels. WITH metrics\_label=label\_name For more detail on usage and considerations, see . | ||
min\_checkpoint\_frequency | Duration string | Controls how often a node’s changefeed will flush their progress to the . A node’s changefeed aggregator will wait at least the specified duration between sending progress updates for the ranges it is watching to the coordinator. This can help you control the flush frequency of higher latency sinks to achieve better throughput. However, more frequent checkpointing can increase CPU usage. If this is set to 0s, a node will flush messages as long as the high-water mark has increased for the ranges that particular node is processing. If a changefeed is resumed, then min\_checkpoint\_frequency is the amount of time that changefeed will need to catch up. That is, it could emit during this time. Note:resolved messages will not be emitted more frequently than the configured min\_checkpoint\_frequency (but may be emitted less frequently). If you require resolved messages more frequently than 30s, you must configure min\_checkpoint\_frequency to at least the desired resolved message frequency. For more details, refer to . Default:30s | |
mvcc\_timestamp | N/A | Include the timestamp for each emitted row in a changefeed. With the mvcc\_timestamp option, each emitted row will always contain its MVCC timestamp, even during the changefeed’s initial backfill. | |
on\_error | pause / fail | Use on\_error=pause to pause the changefeed when encountering non-retryable errors. on\_error=pause will pause the changefeed instead of sending it into a terminal failure state. Note: Retryable errors will continue to be retried with this option specified. Use with protect\_data\_from\_gc\_on\_pause to protect changes from . If a changefeed with on\_error=pause is running when a watched table is , the changefeed will pause but will not be able to resume reads from that table. Using to drop the table from the changefeed and then will work, but you cannot add the same table to the changefeed again. Instead, you will need to create a new changefeed for that table. Default: on\_error=fail | |
protect\_data\_from\_gc\_on\_pause | N/A | This option is deprecated as of v23.2 and will be removed in a future release. When a , ensure that the data needed to is not garbage collected. If protect\_data\_from\_gc\_on\_pause is unset, pausing the changefeed will release the existing protected timestamp records. It is also important to note that pausing and adding protect\_data\_from\_gc\_on\_pause to a changefeed will not protect data if the window has already passed. Use with on\_error=pause to protect changes from garbage collection when encountering non-retryable errors. Refer to for more detail on protecting changefeed data. Note: If you use this option, changefeeds that are left paused for long periods of time can prevent garbage collection. Use with the gc\_protect\_expires\_after option to set a limit for protected data and for how long a changefeed will remain paused. | |
pubsub\_sink\_config | Set fields to configure sink batching and retries. The schema is as follows: { "Flush": { "Messages": ..., "Bytes": ..., "Frequency": ..., }, "Retry": {"Max": ..., "Backoff": ..., } }. Note that if either Messages or Bytes are nonzero, then a non-zero value for Frequency must be provided. Refer to for more details on using this option. | ||
resolved | Duration string | Emit in a format dependent on the connected sink. Resolved timestamps do not emit until the changefeed job’s progress has been checkpointed. Set a minimum amount of time that the changefeed’s high-water mark (overall resolved timestamp) must advance by before another resolved timestamp is emitted. Example: resolved='10s'. This option will only emit a resolved timestamp if the timestamp has advanced (and by at least the optional duration, if set). If a duration is unspecified, all resolved timestamps are emitted as the high-water mark advances. Note: If you set resolved lower than 30s, then you must also set min\_checkpoint\_frequency to at minimum the same value as resolved, because resolved messages may be emitted less frequently than min\_checkpoint\_frequency, but cannot be emitted more frequently. Refer to for more detail. | |
schema_change_events | default / column_changes | The type of schema change event that triggers the behavior specified by the schema_change_policy option:
schema_change_events=default | |
schema_change_policy | backfill / nobackfill / stop | The behavior to take when an event specified by the schema_change_events option occurs:
schema_change_policy=backfill | |
split\_column\_families | N/A | Use this option to create a changefeed on a table with multiple . The changefeed will emit messages for each of the table’s column families. See for more usage detail. | |
topic\_in\_value | Set to include the topic in each emitted row update. This option is automatically set for . Note:topic\_in\_value is not compatible with changefeeds running in parquet format. | ||
unordered | N/A | Run a changefeed to without specifying a region. You must include the unordered option with key\_column in your changefeed creation statement. You cannot use unordered with resolved, because resolved timestamps may not be correct in unordered mode. | |
updated | N/A | Include updated timestamps with each row. If a cursor is provided, the “updated” timestamps will match the timestamps of the emitted rows, and there is no initial scan. If a cursor is not provided, the changefeed will perform an initial scan (as of the time the changefeed was created), and the “updated” timestamp for each change record emitted in the initial scan will be the timestamp of the initial scan. Similarly, when a , the “updated” timestamp is set to the first timestamp for when the new schema is valid. | |
virtual\_columns | STRING | Changefeeds omit from emitted by default. To maintain the behavior of previous CockroachDB versions where the changefeed would emit values for virtual computed columns, set virtual\_columns = "null" when you start a changefeed. You may also define virtual\_columns = "omitted", though this is already the default behavior for v22.1+. If you do not set "omitted" on a table with virtual computed columns when you create a changefeed, you will receive a warning that changefeeds will filter out virtual computed values. Default:"omitted" | |
webhook\_auth\_header | Pass a value (password, token etc.) to the HTTP Authorization header with a webhook request for a “Basic” HTTP authentication scheme. Example: With a username of “user” and password of “pwd”, add a colon between “user:pwd” and then base64 encode, which results in “dXNlcjpwd2Q=”. WITH webhook\_auth\_header='Basic dXNlcjpwd2Q='. | ||
webhook\_client\_timeout | If a response is not recorded from the sink within this timeframe, it will error and retry to connect. Note this must be a positive value. Default:"3s" | ||
webhook\_sink\_config | Set fields to configure sink batching and retries. The schema is as follows: { "Flush": { "Messages": ..., "Bytes": ..., "Frequency": ..., }, "Retry": {"Max": ..., "Backoff": ..., } }. Note that if either Messages or Bytes are nonzero, then a non-zero value for Frequency must be provided. See for more details on using this option. |
Using the
format=avro, envelope=key_only, and updated options together is rejected. envelope=key_only prevents any rows with updated fields from being emitted, which makes the updated option meaningless.Files
The files emitted to a sink use the following naming conventions:The timestamp format is
YYYYMMDDHHMMSSNNNNNNNNNLLLLLLLLLL.General file format
partition_format query parameter. This will result in the following file path formats:
-
daily: This is the default option and will follow the same pattern as the previous general file format. -
hourly: This will partition into an hourly directory as the changefeed emits messages, like the following: -
flat: This will result in no file partitioning. The cloud storage path you specify when creating a changefeed will store all of the message files with no additional directories created.
Resolved file format
Examples
Before running any of the examples in this section it is necessary to . If you are working on a CockroachDB Standard or Basic cluster, this cluster setting is enabled by default. The following examples show the syntax for managing changefeeds and starting changefeeds with different use cases and features. The Options table on this page provides a list of all the available options. For information on sink-specific query parameters and configurations, refer to the page. You can create an external connection to represent a changefeed sink URI. This allows you to specify the external connection’s name in statements rather than the provider-specific URI. For detail on using external connections, see the page. We recommend limiting the number of changefeeds per cluster to 80.Create a changefeed connected to a sink
- (in Preview)
- / HTTP
Create a changefeed that filters and transforms change data
can filter and transform change data before emitting it to a sink or a SQL client. You can adapt a changefeed with CDC queries by includingSELECT and WHERE clauses in your CREATE statement:
Create a sinkless changefeed
You can create a changefeed that will send messages to the SQL client rather than a sink:Use an external connection to specify a changefeed sink
provide a way to define a name for a sink, which you can use instead of the provider-specific URI. To restrict a user’s access to changefeed data and sink credentials, enable thechangefeed.permissions.require_external_connection_sink.enabled cluster setting. When you enable this setting, users with the on a set of tables can only create changefeeds into .
External connections support all changefeed sinks.
Filter changefeeds for tables using row-level TTL
Use thettl_disable_changefeed_replication table storage parameter to prevent changefeeds from sending DELETE messages issued by row-level TTL jobs for a table. Include the storage parameter when you create or alter the table. For example:
sql.ttl.changefeed_replication.disabled to true. This will prevent changefeeds from emitting deletes issued by all TTL jobs on a cluster.
If you want to have a changefeed ignore the storage parameter or cluster setting that disables changefeed replication, you can set the changefeed option ignore_disable_changefeed_replication to true:
Disallow schema changes on tables to improve changefeed performance
Use theschema_locked to indicate that a is not currently ongoing on a watched table. This allows the changefeed to take a fast path that avoids checking if there are schema changes that could require synchronization between . This helps to decrease the latency between a write committing to a table and it emitting to the .
Enable schema_locked on the watched table with the statement:
schema_locked before performing a schema change and reapply it when done. However, certain schema changes (such as ALTER TABLE... SET LOCALITY) cannot automatically unset it. For these cases, you must manually unlock the table with schema_locked = false, complete the schema change, and then lock the table again with schema_locked = true. The changefeed will run as normal while schema_locked is unset, but it will not benefit from the performance optimization.
Manage a changefeed
For changefeed jobs, use to check the status:Pause a changefeed
Resume a paused changefeed
Cancel a changefeed
Modify a changefeed
To modify a changefeed, the job and then use:Configuring all changefeeds
It is useful to be able to pause all running changefeeds during troubleshooting, testing, or when a decrease in CPU load is needed. To pause all running changefeeds:paused, which can be verified with .
To resume all running changefeeds:
running.
Start a new changefeed where another ended
In some situations, you may want to start a changefeed where a previously running changefeed ended. For example, a changefeed could encounter an error it cannot recover from, such as when a , and you need to restart the changefeed.-
Use to find the for the ended changefeed:
If a changefeed has failed, you must restart the changefeed from a timestamp after the event that caused the failure.
-
Use the
high_water_timestampto start the new changefeed:
cursor option to start a changefeed, it will not perform an initial scan.
Create a changefeed with an S3 storage class
To associate the changefeed message files with a in your Amazon S3 bucket, use theS3_STORAGE_CLASS parameter with the class. For example, the following S3 connection URI specifies the INTELLIGENT_TIERING storage class:
Define a key to determine the changefeed sink partition
With thekey_column option, you can define the key used in message metadata that determines the partition for the changefeed message at your . This option overrides the default :
key_column does not preserve ordering of messages from CockroachDB to the downstream sink, therefore you must include the unordered option. It does not affect per-key or the output of key_in_value.

