# /usr/local/cassandra/bin/cqlsh --help
Usage: cqlsh [options] [host [port]]
CQL Shell for Apache Cassandra
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-C, --color Always use color output
--no-color Never use color output
-u USERNAME, --username=USERNAME
Authenticate as user.
-p PASSWORD, --password=PASSWORD
Authenticate using password.
-k KEYSPACE, --keyspace=KEYSPACE
Authenticate to the given keyspace.
-f FILE, --file=FILE Execute commands from FILE, then exit
-t TRANSPORT_FACTORY, --transport-factory=TRANSPORT_FACTORY
Use the provided Thrift transport factory function.
--debug Show additional debugging information
--cqlversion=CQLVERSION
Specify a particular CQL version (default: 3).
Examples: "2", "3.0.0-beta1"
-2, --cql2 Shortcut notation for --cqlversion=2
-3, --cql3 Shortcut notation for --cqlversion=3
Connects to localhost:9160 by default. These defaults can be changed by
setting $CQLSH_HOST and/or $CQLSH_PORT. When a host (and optional port number)
are given on the command line, they take precedence over any defaults.
cqlsh:Hogebook> help
Documented shell commands:
===========================
ASSUME CONSISTENCY DESC EXIT SHOW TRACING
CAPTURE COPY DESCRIBE HELP SOURCE
CQL help topics:
================
ALTER CREATE_KEYSPACE SELECT_EXPR
ALTER_ADD CREATE_TABLE SELECT_LIMIT
ALTER_ALTER CREATE_TABLE_OPTIONS SELECT_TABLE
ALTER_DROP CREATE_TABLE_TYPES SELECT_WHERE
ALTER_WITH DELETE TEXT_OUTPUT
APPLY DELETE_COLUMNS TIMESTAMP_INPUT
ASCII_OUTPUT DELETE_USING TIMESTAMP_OUTPUT
BEGIN DELETE_WHERE TRUNCATE
BLOB_INPUT DROP TYPES
BOOLEAN_INPUT DROP_COLUMNFAMILY UPDATE
CONSISTENCYLEVEL DROP_INDEX UPDATE_COUNTERS
CREATE DROP_KEYSPACE UPDATE_SET
CREATE_COLUMNFAMILY DROP_TABLE UPDATE_USING
CREATE_COLUMNFAMILY_OPTIONS INSERT UPDATE_WHERE
CREATE_COLUMNFAMILY_TYPES SELECT USE
CREATE_INDEX SELECT_COLUMNFAMILY UUID_INPUT
さらに、各コマンドでhelpを打つと詳細が分かります。
cqlsh:Hogebook> help SELECT
SELECT [FIRST n] [REVERSED] <selectExpr>
FROM [<keyspace>.]
[USING CONSISTENCY <consistencylevel>]
[WHERE <clause>]
[ORDER BY <colname> [DESC]]
[LIMIT m];
SELECT is used to read one or more records from a CQL table. It returns
a set of rows matching the selection criteria specified.
Note that FIRST and REVERSED are only supported in CQL 2, and ORDER BY
is only supported in CQL 3 and higher.
For more information, see one of the following:
HELP SELECT_EXPR
HELP SELECT_TABLE
HELP SELECT_WHERE
HELP SELECT_LIMIT
HELP CONSISTENCYLEVEL
このように、とてもSQLライクに使えるようです。
いくつかコマンドを打ってみたいと思います。
○DESC TABLE
cqlsh:Hogebook> desc table User;
CREATE TABLE User (
KEY text PRIMARY KEY,
email text,
gender text
) WITH
comment='' AND
comparator=text AND
read_repair_chance=0.100000 AND
gc_grace_seconds=864000 AND
default_validation=text AND
min_compaction_threshold=4 AND
max_compaction_threshold=32 AND
replicate_on_write='true' AND
compaction_strategy_class='SizeTieredCompactionStrategy' AND
compression_parameters:sstable_compression='SnappyCompressor';
CREATE INDEX User_gender_idx ON User (gender);