Export/Import Data in Cassandra Table | Tech Talks
This post shows how to export data from a cassandra table into a csv file.For test purpose, I created a sample employee table with only 2 rows in it.
cqlsh> use demodb ;
cqlsh:demodb> select * from emp;
empid | deptid | first_name | last_name
-------+--------+------------+-----------
1 | 15 | james | smith
104 | 15 | jane | smith
(2 rows)
Please note we can export data to CSV file in another order by mentioning the column names in parentheses as show below. As you will notice, I put last_name before first_name
cqlsh:demodb> COPY emp (empid, deptid, last_name, first_name) TO 'temp.csv' ;
2 rows exported in 0.011 seconds.
To verify , if we actually exported the rows in 'temp.csv' , lets go check out the results.
Vishals-MacBook-Air:bin vishalshukla$ cat temp.csv
1,15,smith,james
Read full article from Export/Import Data in Cassandra Table | Tech Talks
No comments:
Post a Comment