Skip to main content
This page has instructions for migrating data from a CockroachDB Standard cluster to a CockroachDB Advanced cluster, by exporting to CSV and using . You may want to migrate to CockroachDB Advanced if you want a single-tenant cluster with no shared resources. The following steps use sample data from the .

Before you begin

These instructions assume you already have the following:
  • A from which you want to migrate data.
  • A .
  • .

Step 1. Export data to cloud storage

First, upload your CockroachDB Standard data to a cloud storage location where the CockroachDB Advanced cluster can access it.
  1. and run the statement for each table you need to migrate. For example, the following statement exports the warehouse table from the database to an Amazon S3 bucket:
    This command uploads the table in CSV format to a migration-data directory in the S3 bucket. The output shows the programmatically generated filename, which you’ll reference when you import the CSV:
    The export file contains the following CSV data:
  2. Repeat this step for each table you want to migrate. For example, export one more table (district) from the tpcc database:
    The export file contains the following CSV data:
For more information about using cloud storage with CockroachDB, refer to .

Step 2. Import the CSV

For best practices for optimizing import performance in CockroachDB, refer to .
  1. and you want to import the tables into. For example:
  2. Write a statement that matches the schema of the table data you’re importing.
You can use the statement in the CockroachDB Standard cluster to view the CREATE statement for the table you’re migrating.
The column order in your schema must match the column order in the file being imported.
For example, to import the tpcc.warehouse data into a warehouse table, issue the following statement to create the new table:
Next, use IMPORT INTO to import the data into the new table, specifying the filename of the export from Step 1:
  1. Repeat the previous command for each CSV file you want to import. For example, import the tpcc.district data: Issue the following statement to create a new district table:
    Next, use IMPORT INTO to import the data into the new table, specifying the filename of the export from Step 1:
  2. (Optional) To verify that the data was imported, use :

Step 3. Add any foreign key relationships

Once all of the tables you want to migrate have been imported into the CockroachDB Advanced cluster, add the relationships. To do this, use . For example:

See also