How to select data from a table and insert into another table?

ehsan shirzadi picture ehsan shirzadi · Jan 26, 2014 · Viewed 26.7k times · Source

I want to select specific fields of a table in cassandra and insert them into another table. I do this in sql server like this:

INSERT INTO Users(name,family)
SELECT name,family FROM Users

How to to this in cassandra-cli or cqlsh?

Answer

Helping Hand.. picture Helping Hand.. · Jan 27, 2014
COPY keyspace.columnfamily1 (column1, column2,...) TO 'temp.csv';
COPY keyspace.columnfamily2 (column1, column2,...) FROM 'temp.csv';

here give your keyspace(schema-name) and instead of columnfamilyname1 use the table to which you want to copy and in columnfamily2 give the tablename in which you want to copy..

And yes this is solution for CQL,however I have never tried in with CLI.