Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Cassandra query API-cqlsh

Shulou Source: shulou.com Published: 2022-06-02 19:06:46 11月09日 Update

By default, Cassandra provides a prompt Cassandra query language shell (cqlsh) to facilitate user configuration debugging.

With cqlsh, you can do the following:

Define schemas, insert data, and execute queries. General command option usage introduction cqlsh-- help displays a help topic about options for the cqlsh command. Cqlsh-- version provides the version of cqlsh that you are using. Cqlsh-- color instructs shell to use color output. Cqlsh-- debug displays more debugging information. Cqlsh-- execute instructs shell to accept and execute the CQL command. Cql_statement instructs shell to accept and execute the CQL command. Cqlsh-- file= "file name" if you use this option, Cassandra will execute the command and exit in the given file. Cqlsh-- no-color instructs Cassandra not to use color output. Cqlsh-u "user name" uses this option to authenticate users. The default user name is cassandra. Cqlsh-p "pass word" uses this option, and you can authenticate the user with a password. The default password is cassandra. Start the cqlsh method:

Start cqlsh using the command cqlsh

Cqlsh 172.20.101.252-u cassandra-p cassandra default user, password: cassandra returns result: Connected to cn-engage-dev at 172.20.101.252 Connected to cn-engage-dev at 9042. [cqlsh 5.0.1 | Cassandra 3.11.4 | CQL spec 3.4.4 | Native protocol v4] Cqlsh command HELP-displays the help topics for all cqlsh commands. CAPTURE-captures the output of the command and adds it to the file. CONSISTENCY-displays the current conformance level or sets a new conformance level. COPY-copy data to Cassandra and copy data from Cassandra. DESCRIBE-describes the current cluster of Cassandra and its objects. EXPAND-output of the scale-up query. EXIT-use this command to terminate cqlsh. PAGING-enables or disables query paging. SHOW-displays details of the current cqlsh session, such as Cassandra version, host or data type assumptions. SOURCE-executes the file that contains the CQL statement. TRACING-enables or disables request tracking. The CQL data definition command CREATE KEYSPACE-creates a KeySpace in Cassandra. USE-Connect to the created KeySpace. ALTER KEYSPACE-change the properties of the KeySpace. DROP KEYSPACE-Delete the KeySpace. CREATE TABLE-create tables in KeySpace. ALTER TABLE-modifies the column properties of the table. DROP TABLE-deletes the table. TRUNCATE-removes all data from the table. CREATE INDEX-defines a new index on a single column of the table. DROP INDEX-deletes the named index. CQL data manipulation instruction INSERT-columns that add rows to the table. UPDATE-the column that updates the row. DELETE-removes data from the table. BATCH-execute more than one DML statement at a time. CQL sentence SELECT-this clause reads data from a table-the WHERE-where clause is used with select to read specific data. The ORDERBY-orderby clause is used with select to read specific data in a specific order.

Tags: Commands data users queries instructions output clauses passwords files consistency topics information attributes colors versions indexes levels statements Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Technology Apple vpn NVidia