IMPORT INTO. 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 tpcc workload.
Before you begin
These instructions assume you already have the following:- A CockroachDB Standard cluster from which you want to migrate data.
- A CockroachDB Advanced cluster.
- Cloud storage.
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.-
Connect to your CockroachDB Standard cluster and run the
EXPORTstatement for each table you need to migrate. For example, the following statement exports thewarehousetable from thetpccdatabase to an Amazon S3 bucket:This command uploads the table in CSV format to amigration-datadirectory 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: -
Repeat this step for each table you want to migrate. For example, export one more table (
district) from thetpccdatabase:The export file contains the following CSV data:
Step 2. Import the CSV
-
Connect to your CockroachDB Advanced cluster and create the database you want to import the tables into. For example:
-
Write a
CREATE TABLEstatement that matches the schema of the table data you’re importing.
The column order in your schema must match the column order in the file being imported.
tpcc.warehouse data into a warehouse table, issue the following statement to create the new table:
IMPORT INTO to import the data into the new table, specifying the filename of the export from Step 1:
-
Repeat the previous command for each CSV file you want to import. For example, import the
tpcc.districtdata: Issue the following statement to create a newdistricttable:Next, useIMPORT INTOto import the data into the new table, specifying the filename of the export from Step 1: -
(Optional) To verify that the data was imported, use
SHOW TABLES:
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 foreign key relationships. To do this, useALTER TABLE... ADD CONSTRAINT. For example:

