cassandra 2.0 - copy

nosql 2013. 11. 8. 15:35


기존의 db를 사용했던 사람이라면 db의 테이블로부터 csv로 export 하는 기능을 많이 활용한다.  cassandra 2.0의 cql copy 명령어를 이용하면 export/import 기능을 사용할 수 있다. 


cassandra 2.0에 copy statement를 사용할 수 있다.

http://www.datastax.com/documentation/cql/3.1/webhelp/index.html#cql/cql_reference/copy_r.html






cqlsh:userkeyspace> describe table cf33


CREATE TABLE cf33 (

  key text,

  name text,

  number text,

  PRIMARY KEY (key)

) WITH

  bloom_filter_fp_chance=0.010000 AND

  caching='KEYS_ONLY' AND

  comment='' AND

  dclocal_read_repair_chance=0.000000 AND

  gc_grace_seconds=864000 AND

  index_interval=128 AND

  read_repair_chance=0.100000 AND

  replicate_on_write='true' AND

  populate_io_cache_on_flush='false' AND

  default_time_to_live=0 AND

  speculative_retry='NONE' AND

  memtable_flush_period_in_ms=0 AND

  compaction={'class': 'SizeTieredCompactionStrategy'} AND

  compression={'sstable_compression': 'LZ4Compressor'};


CREATE INDEX name ON cf33 (name);


cqlsh:userkeyspace> select * from cf33;


 key  | name | number

------+------+--------

 row1 | John |      2


(1 rows)


cqlsh:userkeyspace> copy cf33 to 'cf33.csv';

1 rows exported in 0.008 seconds.

cqlsh:userkeyspace> truncate cf33;

cqlsh:userkeyspace> select * from cf33;


(0 rows)



cqlsh:userkeyspace> copy cf33(key, name,number) from 'cf33.csv';

1 rows imported in 0.034 seconds.

cqlsh:userkeyspace> select * from cf33;


 key  | name | number

------+------+--------

 row1 | John |      2


(1 rows)





Posted by '김용환'
,