section
qa
answer
CQLSH Specific
Login
$ cqlsh [node_ip] -u username -p password
CQLSH Specific
Use Color
$ cqlsh [node_ip] -C -u username -p password
CQLSH Specific
Execute command
$ cqlsh -e ‘describe cluster’
CQLSH Specific
Execute from file
$ cqlsh -f cql_commands.cql
CQLSH Specific
Set consistency
$cqlsh> CONSISTENCY QUORUM ;
CQLSH Specific
Run commands from file
$cqlsh> SOURCE ‘/home/cjrolo/cql_commands.cql’ ;
CQLSH Specific
Capture output to file
$cqlsh> CAPTURE ‘/home/cjrolo/cql_output.cql’ ;
CQLSH Specific
Enable Tracing
$cqlsh> TRACING ONE;
CQLSH Specific
Vertical Printing of Rows
$cqlsh> EXPAND ON;
CQLSH Specific
Print tracing session
$cqlsh> SHOW SESSION 898de000-6d83-11e8-9960-3d86c0173a79;
CQL Commands
Create Keyspace
CREATE KEYSPACE carlos WITH replication = {‘class’: ‘SimpleStrategy’, ‘replication_factor’ : 3};
CQL Commands
Alter Keyspace
ALTER KEYSPACE carlos WITH replication = {‘class’: ‘SimpleStrategy’, ‘replication_factor’ : 1};
CQL Commands
Drop Keyspace
DROP KEYSPACE carlos;
CQL Commands
Create Table
CREATE TABLE carlos.foobar (foo int PRIMARY KEY,bar int);
CQL Commands
Alter Table
ALTER TABLE carlos.foobar WITH compaction = { ‘class’ : ‘LeveledCompactionStrategy’} AND read_repair_chance = 0;
CQL Commands
Drop Table
DROP TABLE foobar;
CQL Commands
Create Role
CREATE ROLE admins WITH LOGIN = true AND SUPERUSER = true;
CQL Commands
Create User
CREATE USER carlos WITH PASSWORD ‘some_password’ NOSUPERUSER;
CQL Commands
Assign Role
GRANT admins TO carlos;
CQL Commands
Revoke Role
REVOKE admins FROM carlos;
CQL Commands
List Roles
LIST ROLES;
CQL Commands
Use Keyspace
USE carlos;
CQL Commands
Insert
INSERT INTO foobar (foo, bar) VALUES (0, 1);
CQL Commands
Insert with TTL
INSERT INTO foobar (foo, bar) VALUES (1, 2) USING TTL 3600;
CQL Commands
Update
UPDATE foobar SET bar = 42 WHERE foo = 1;
CQL Commands
Select
SELECT * FROM foobar WHERE foo=0;
CQL Commands
Delete
DELETE FROM foobar WHERE foo = 1;