CREATE SCHEDULE FOR CHANGEFEED allows you to create a scheduled changefeed to export data out of CockroachDB. Scheduled changefeeds have the scale, observability, and endpoint sink options that changefeed jobs include, with the convenience of setting a regular schedule. A changefeed job created with CREATE SCHEDULE FOR CHANGEFEED performs a one-time table scan using the functionality to create an export of your table data.
For more detail on using changefeeds to create an export of your table data, see .
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. |
Deprecated CONTROLCHANGEFEED 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 |
|---|---|
IF NOT EXISTS | A scheduled changefeed should not be created if the schedule_label already exists. You will receive an error if the schedule label already exists, or if schedule_label is not defined when using IF NOT EXISTS. |
schedule_label | The name for the scheduled changefeed. This is optional and does not need to be unique. If you do not define a name, the label will default to CHANGEFEED with the timestamp of when you created the schedule. |
changefeed_targets | The tables to target with the changefeed. For example, movr.users, movr.rides. |
changefeed_sink | The . |
changefeed_option | The to control the behavior of your changefeed. For example, WITH format = csv, full_table_name. See Changefeed options for a list of available options. |
target_list | The columns to emit data from if you’re using a expression. |
insert_target | The target tables for the changefeed if you’re using a expression. |
where_clause | An optional WHERE clause to apply filters to the table if you’re using a expression. |
crontab | The frequency of the changefeed. The schedule is specified as a STRING in crontab format. All times in UTC. For example, '@daily', '@hourly', '1 0 * * *'. |
schedule_option | The schedule options to control the schedule’s behavior. For example, first_run = now. See Schedule options. |
Changefeed options
You can include the changefeed options listed on the page to modify the behavior of your changefeed. The following options are not compatible with scheduled changefeeds:diffend_timemvcc_timestampresolvedupdated
initial_scan as 'yes' or 'no'.
Schedule options
To avoid multiple clusters running the same schedule concurrently, changefeed schedules will when onto a different cluster or after has completed.
Examples
Before running any of the examples in this section, it is necessary to enable thekv.rangefeed.enabled cluster setting. If you are working on a CockroachDB Standard or Basic cluster, this cluster setting is enabled by default.
The page provides detail on the available sinks for your change data messages and connection URIs. We recommend using to interact with external sinks. The examples in this section use an external connection URI for the changefeed sink.
Create a scheduled changefeed
The following statement sets up a scheduled changefeed namedusers_rides_nightly that will send changefeed messages in CSV format 1 minute past midnight every night. As soon as the statement is run, the first changefeed run will execute immediately:
- If it runs into an error,
on_execution_failure=retrywill ensure that the schedule retries the changefeed immediately. - If the previous scheduled changefeed is still running,
on_previous_running=skipwill skip a new changefeed at the next scheduled time.
initial_scan = 'only' option implicitly:

