Skip to content

Instantly share code, notes, and snippets.

@jeffjirsa
Created April 6, 2016 19:42
Show Gist options
  • Save jeffjirsa/79ebd04e57b3ca3924500218e0ed917c to your computer and use it in GitHub Desktop.
Save jeffjirsa/79ebd04e57b3ca3924500218e0ed917c to your computer and use it in GitHub Desktop.
cqlsh> create keyspace test with replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
cqlsh> use test;
cqlsh:test> drop table if exists test0;
cqlsh:test> CREATE TABLE test0 (
... pk int,
... a int,
... b text,
... s text static,
... PRIMARY KEY (pk, a)
... );
cqlsh:test>
cqlsh:test> insert into test0 (pk,a,b,s) values (0,1,'b1','hello b1');
cqlsh:test> insert into test0 (pk,a,b,s) values (0,2,'b2','hello b2');
cqlsh:test> insert into test0 (pk,a,b,s) values (0,3,'b3','hello b3');
cqlsh:test> create index on test0 (b);
cqlsh:test> insert into test0 (pk,a,b,s) values (0,2,'b2 again','b2 again');
cqlsh:test> select * from test0 where pk=0 and a=2;
pk | a | s | b
----+---+----------+----------
0 | 1 | b2 again | b1
0 | 2 | b2 again | b2 again
0 | 3 | b2 again | b3
(3 rows)
cqlsh:test>
cqlsh:test>
cqlsh:test> drop table test0;
cqlsh:test> CREATE TABLE test0 (
... pk int,
... a int,
... b text,
... s text ,
... PRIMARY KEY (pk, a)
... );
cqlsh:test> insert into test0 (pk,a,b,s) values (0,1,'b1','hello b1');
cqlsh:test> insert into test0 (pk,a,b,s) values (0,2,'b2','hello b2');
cqlsh:test> insert into test0 (pk,a,b,s) values (0,3,'b3','hello b3');
cqlsh:test> create index on test0 (b);
cqlsh:test> insert into test0 (pk,a,b,s) values (0,2,'b2 again','b2 again');
cqlsh:test> select * from test0 where pk=0 and a=2;
pk | a | b | s
----+---+----------+----------
0 | 2 | b2 again | b2 again
(1 rows)
cqlsh:test>
cqlsh:test> ^D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment