Export Data with Changefeeds

On this page Carat arrow pointing down
Warning:
As of November 24, 2023, CockroachDB v22.1 is no longer supported. For more details, refer to the Release Support Policy.

New in v22.1: When you create an Enterprise changefeed, you can include the initial_scan = 'only' option to specify that the changefeed should only complete a table scan. The changefeed emits messages for the table scan and then the job completes with a succeeded status. As a result, you can create a changefeed with initial_scan = 'only' to export data out of your database.

The benefits of using changefeeds for this function compared to an export, include:

Although this option offers an alternative way to export data out of your database, it is necessary to consider the following when you use CREATE CHANGEFEED instead of EXPORT:

Note:

You cannot use the new initial_scan = "yes"/"no"/"only" syntax with
ALTER CHANGEFEED in v22.1. To ensure that you can modify a changefeed with the initial_scan options, use the previous syntax of initial_scan, no_initial_scan, and initial_scan_only.

To create a changefeed that will only complete an initial scan of a table(s), run the following:

CREATE CHANGEFEED FOR TABLE movr.users INTO '{scheme}://{host}:{port}?{query_parameters}' WITH initial_scan = 'only', format=csv;

The job will return a job ID once it has started. You can use SHOW CHANGEFEED JOBS to check on the status:

SHOW CHANGEFEED JOB {job ID};

When the scan has completed you will find the output shows succeeded in the status field.

See also


Yes No
On this page

Yes No