Using COPY to Import and Export Data

Scenarios

The COPY command is one of cqlsh commands. It includes COPY TO and COPY FROM. They are used to copy data to and from Cassandra.

You can run the COPY TO command to export data from an existing Cassandra instance and then run the COPY FROM command to import the data to an RDBMS instance or a new Cassandra instance. Currently, you can copy data to or from the CSV and JSON files.

Precautions

You are advised to import and export data during off-peak hours to avoid the impact on your services.

Prerequisites

You have connected to a DB instance. For details, see Connecting to a GaussDB(for Cassandra) Instance Over Private Networks.

Method

COPY TO

Parameter description:

The common parameters are as follows: NUMPROCESSES, RATEFILE, PAGESIZE, BEGINTOKEN, ENDTOKEN, MAXATTEMPTS, and MAXOUTPUTSIZE.

The newly added parameters are as follows: RESULTFILE, DATAFORMATS, and WHERECONDITION.

For details about other COPY TO parameters, see the Cassandra official documentation.

COPY FROM

Parameter description:

The common parameters are as follows: NUMPROCESSES, MAXROWS, INGESTRATE, ERRFILE, MAXBATCHSIZE, MINBATCHSIZE, CHUNKSIZE, MAXPARSEERRORS, MAXINSERTERRORS, SKIPROWS, and SKIPCOLS.

The newly added parameter is DATAFORMATS.

For details about other COPY FROM parameters, see the Cassandra official documentation.