cassandra copy data from one columnfamily to another columnfamily

前端 未结 3 1443
时光取名叫无心
时光取名叫无心 2021-01-02 08:29

I am newbie to cassandra . I need to copy data from one columnFamily to another columnFamily in same keyspace in cassandra .Say for ex we have a A1 columnFamily in keyspace

相关标签:
3条回答
  • Please be aware of a limit of max. 2 million rows when using the COPY command. See https://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlshCopy.html

    Note: Only use COPY FROM to import datasets that have less than 2 million rows. To import large datasets, use the Cassandra bulk loader

    0 讨论(0)
  • 2021-01-02 08:40

    cqlsh -k mykeyspace -e 'COPY fromTable(columnNames) TO STDOUT' | head -n -1 | cqlsh -k mykeyspace -e 'COPY toTable(columnNames) FROM STDIN'

    0 讨论(0)
  • 2021-01-02 08:48

    Depending on the cassandra version you can use the copy cql command. To use that you need a cql client like the one that is distributted with cassandra.

    First you have to copy the columnfamily A1 to a CSV file using:

    COPY K1.A1 (column1, column2,...) TO 'temp.csv';
    

    And after that copy the file to the new column family

    COPY K1.A2 (column1, column2,...) FROM 'temp.csv';
    

    Obviously you have to change the name of the columns to your names.

    More information:

    http://www.datastax.com/documentation/cassandra/1.2/index.html#cassandra/cql_reference/copy_r.html

    0 讨论(0)
提交回复
热议问题