0

I am a newbie to cassandra. is there a way to copy data from one column family from a key space to another keyspace?

We have an application, that generates new keyspaces of same column families. We are thinking to merge all them into one keyspace per tenant.

any commands or util available to do this?

Thanks in advance.

Community
  • 1
  • 1
Divakar
  • 21
  • 3

1 Answers1

1

you can use copy command in cqlsh..

COPY keyspacename1.columnfamilyname1 (id, name, email) TO 'temp.csv';

COPY keyspacename2.columnfamilyname2 (id, name, email) FROM 'temp.csv';

Helping Hand..
  • 2,430
  • 4
  • 32
  • 52
  • 1
    SQL Error: line 1:0 no viable alternative at input 'COPY' 'COPY Divakar.'5011' (associatedMatterName, collectedDate) TO 'temp.csv'' line 1:0 no viable alternative at input 'COPY' 'COPY Divakar.'5011' (associatedMatterName, collectedDate) TO 'temp.csv'' InvalidRequestException I tried your query, but i got this exception. I tried the query in DBeaver sql editor – Divakar Nov 18 '14 at 08:48
  • above is cqlsh query.. so use respected key-space and execute it. – Helping Hand.. Nov 18 '14 at 08:55
  • is it possible to copy the data from data directory and paste it to a similar keyspace which has the same columnfamily and make it work? – Divakar Nov 19 '14 at 04:36
  • Divakar, you can try export columfamility data to a json file and them import it where you want. I described approach here https://stackoverflow.com/a/63842723/586609 – Stanislav Berkov Sep 11 '20 at 07:47