CQLAI Commands Reference
CQLAI supports all standard CQL commands plus additional meta-commands and AI features for enhanced functionality.
CQL Commands
Section titled “CQL Commands”Execute any valid CQL statement supported by your Cassandra cluster:
Data Definition (DDL)
Section titled “Data Definition (DDL)”-- KeyspacesCREATE KEYSPACE my_keyspace WITH replication = { 'class': 'NetworkTopologyStrategy', 'dc1': 3};ALTER KEYSPACE my_keyspace WITH replication = { 'class': 'NetworkTopologyStrategy', 'dc1': 3, 'dc2': 3};DROP KEYSPACE my_keyspace;
-- TablesCREATE TABLE users ( user_id UUID PRIMARY KEY, username TEXT, email TEXT);ALTER TABLE users ADD phone TEXT;DROP TABLE users;TRUNCATE users;
-- IndexesCREATE INDEX ON users (email);CREATE INDEX users_email_idx ON users (email) USING 'sai';DROP INDEX users_email_idx;
-- User-Defined TypesCREATE TYPE address ( street TEXT, city TEXT, zip TEXT);ALTER TYPE address ADD country TEXT;DROP TYPE address;
-- Functions and AggregatesCREATE FUNCTION my_func(input TEXT) CALLED ON NULL INPUT RETURNS TEXT LANGUAGE java AS 'return input.toUpperCase();';DROP FUNCTION my_func;Data Manipulation (DML)
Section titled “Data Manipulation (DML)”-- InsertINSERT INTO users (user_id, username, email)VALUES (uuid(), 'john_doe', 'john@example.com');
INSERT INTO users (user_id, username, email)VALUES (uuid(), 'temp_user', 'temp@example.com')USING TTL 86400;
-- SelectSELECT * FROM users;SELECT username, email FROM users WHERE user_id = ?;SELECT JSON * FROM users; -- Returns proper JSON
-- UpdateUPDATE users SET email = 'new@example.com'WHERE user_id = 550e8400-e29b-41d4-a716-446655440000;
UPDATE users USING TTL 3600SET temp_field = 'value'WHERE user_id = ?;
-- DeleteDELETE FROM users WHERE user_id = ?;DELETE email FROM users WHERE user_id = ?;
-- BatchBEGIN BATCH INSERT INTO users (user_id, username) VALUES (uuid(), 'user1'); INSERT INTO users (user_id, username) VALUES (uuid(), 'user2');APPLY BATCH;Data Control (DCL)
Section titled “Data Control (DCL)”-- RolesCREATE ROLE admin WITH PASSWORD = 'pass' AND SUPERUSER = true AND LOGIN = true;ALTER ROLE admin WITH PASSWORD = 'newpass';DROP ROLE admin;
-- PermissionsGRANT ALL PERMISSIONS ON KEYSPACE my_app TO admin;GRANT SELECT ON TABLE users TO readonly_role;REVOKE DELETE ON TABLE users FROM app_role;LIST ALL PERMISSIONS OF admin;Meta-Commands
Section titled “Meta-Commands”Session Management
Section titled “Session Management”Switch to a keyspace:
USE my_keyspace;CONSISTENCY
Section titled “CONSISTENCY”Set or show consistency level:
-- Show current levelCONSISTENCY;
-- Set levelCONSISTENCY QUORUM;CONSISTENCY LOCAL_QUORUM;CONSISTENCY ONE;Available levels:
ANY- Write to any node (including hints)ONE- One replicaTWO- Two replicasTHREE- Three replicasQUORUM- Majority of replicasALL- All replicasLOCAL_QUORUM- Majority in local DCEACH_QUORUM- Quorum in each DCLOCAL_ONE- One replica in local DCSERIAL- For lightweight transactionsLOCAL_SERIAL- Local serial
PAGING
Section titled “PAGING”Control result pagination:
-- Show current page sizePAGING;
-- Set page sizePAGING 100;PAGING 1000;
-- Disable pagingPAGING OFF;TRACING
Section titled “TRACING”Enable query tracing:
-- Enable tracingTRACING ON;
-- Run query (trace shown in F4 view)SELECT * FROM users WHERE user_id = ?;
-- Disable tracingTRACING OFF;EXPAND
Section titled “EXPAND”Toggle vertical output mode:
-- Enable expanded outputEXPAND ON;
-- Query shows one field per lineSELECT * FROM users LIMIT 1;
-- Disable expanded outputEXPAND OFF;OUTPUT
Section titled “OUTPUT”Set output format:
-- Show current formatOUTPUT;
-- Set formatOUTPUT TABLE; -- Default table formatOUTPUT JSON; -- JSON formatOUTPUT ASCII; -- ASCII tableOUTPUT EXPAND; -- Expanded vertical formatSchema Description
Section titled “Schema Description”DESCRIBE / DESC
Section titled “DESCRIBE / DESC”View schema information:
-- List all keyspacesDESCRIBE KEYSPACES;
-- Show keyspace definitionDESCRIBE KEYSPACE my_keyspace;
-- List tables in current keyspaceDESCRIBE TABLES;
-- Show table structureDESCRIBE TABLE users;DESC users; -- Short form
-- Show table in specific keyspaceDESC my_keyspace.users;
-- User-Defined TypesDESCRIBE TYPES;DESCRIBE TYPE address;
-- FunctionsDESCRIBE FUNCTIONS;DESCRIBE FUNCTION my_func;
-- AggregatesDESCRIBE AGGREGATES;DESCRIBE AGGREGATE my_agg;
-- Materialized ViewsDESCRIBE MATERIALIZED VIEWS;DESCRIBE MATERIALIZED VIEW user_by_email;
-- IndexesDESCRIBE INDEX users_email_idx;
-- Cluster informationDESCRIBE CLUSTER;Display session information:
-- Show Cassandra versionSHOW VERSION;
-- Show current connectionSHOW HOST;
-- Show all session settingsSHOW SESSION;Data Import/Export
Section titled “Data Import/Export”COPY TO
Section titled “COPY TO”Export table data to file:
-- Export to CSVCOPY users TO 'users.csv';
-- Export to Parquet (auto-detected by extension)COPY users TO 'users.parquet';
-- Export specific columnsCOPY users (id, name, email) TO 'users_partial.csv';
-- Export with optionsCOPY users TO 'users.csv' WITH HEADER=TRUE AND DELIMITER='|';
-- Export to stdoutCOPY users TO STDOUT WITH HEADER=TRUE;
-- Parquet with compressionCOPY users TO 'users.parquet' WITH FORMAT='PARQUET' AND COMPRESSION='SNAPPY';COPY TO Options:
| Option | Default | Description |
|---|---|---|
FORMAT | CSV | Output format: CSV or PARQUET |
HEADER | TRUE | Include column headers (CSV) |
DELIMITER | , | Field separator (CSV) |
NULLVAL | (empty) | String for NULL values |
PAGESIZE | 1000 | Rows per page for large exports |
COMPRESSION | SNAPPY | For Parquet: SNAPPY, GZIP, ZSTD, LZ4, NONE |
CHUNKSIZE | 10000 | Rows per chunk (Parquet) |
COPY FROM
Section titled “COPY FROM”Import data from file:
-- Import from CSVCOPY users FROM 'users.csv';
-- Import from ParquetCOPY users FROM 'users.parquet';
-- Import with header rowCOPY users FROM 'users.csv' WITH HEADER=TRUE;
-- Import specific columnsCOPY users (id, name, email) FROM 'users_partial.csv';
-- Import from stdinCOPY users FROM STDIN;
-- Import with optionsCOPY users FROM 'data.csv' WITH HEADER=TRUE AND DELIMITER='|' AND NULLVAL='N/A';COPY FROM Options:
| Option | Default | Description |
|---|---|---|
FORMAT | CSV | Input format: CSV or PARQUET |
HEADER | FALSE | First row contains headers |
DELIMITER | , | Field separator |
NULLVAL | (empty) | String representing NULL |
MAXROWS | -1 | Max rows to import (-1=unlimited) |
SKIPROWS | 0 | Rows to skip at start |
MAXPARSEERRORS | -1 | Max parse errors allowed |
MAXINSERTERRORS | 1000 | Max insert errors allowed |
MAXBATCHSIZE | 20 | Max rows per batch |
MINBATCHSIZE | 2 | Min rows per batch |
CHUNKSIZE | 5000 | Progress update interval |
ENCODING | UTF8 | File encoding |
QUOTE | " | Quote character |
CAPTURE
Section titled “CAPTURE”Capture query output continuously:
-- Start capturing to text fileCAPTURE 'output.txt';
-- Capture as JSONCAPTURE JSON 'output.json';
-- Capture as CSVCAPTURE CSV 'output.csv';
-- Run queries (output captured)SELECT * FROM users;SELECT * FROM orders;
-- Stop capturingCAPTURE OFF;Save displayed results to file:
-- Run a query firstSELECT * FROM users WHERE status = 'active';
-- Save displayed resultsSAVE; -- Interactive dialogSAVE 'users.csv'; -- Auto-detect formatSAVE 'users.json'; -- JSON formatSAVE 'data.txt' ASCII; -- ASCII tableDifference from CAPTURE: SAVE exports currently displayed results without re-executing the query. CAPTURE records all subsequent query results.
Script Execution
Section titled “Script Execution”SOURCE
Section titled “SOURCE”Execute CQL script from file:
-- Execute scriptSOURCE 'schema.cql';
-- Absolute pathSOURCE '/path/to/script.cql';Display command help:
-- Show all commandsHELP;
-- Help for specific commandHELP DESCRIBE;HELP CONSISTENCY;HELP COPY;AI Commands
Section titled “AI Commands”Generate CQL from natural language:
-- Simple queries.ai show all users.ai find products with price less than 100.ai count orders from last month
-- Complex operations.ai create a table for storing customer feedback with id, customer_id, rating, and comment.ai update user status to inactive where last_login is older than 90 days.ai delete all expired sessions
-- Schema exploration.ai what tables are in this keyspace.ai describe the structure of the users table.ai show me the primary key of the orders tableHow it works:
- Type
.aifollowed by your request - CQLAI extracts your current schema for context
- AI generates a CQL query
- Preview the query before execution
- Execute, edit, or cancel
Safety features:
- Read-only preference (prefers SELECT unless asked otherwise)
- Warnings for destructive operations (DROP, DELETE, TRUNCATE)
- Confirmation required for dangerous queries
- Schema validation
See AI Features Guide for configuration and advanced usage.
Keyboard Shortcuts Reference
Section titled “Keyboard Shortcuts Reference”Navigation & Control
Section titled “Navigation & Control”| Shortcut | Action |
|---|---|
↑ / ↓ | Navigate command history |
Tab | Auto-complete |
Ctrl+C | Clear input / Cancel / Exit (twice) |
Ctrl+D | Exit application |
Ctrl+R | Search command history |
Esc | Toggle navigation mode |
Enter | Execute / Load next page |
Text Editing
Section titled “Text Editing”| Shortcut | Action |
|---|---|
Ctrl+A | Jump to beginning of line |
Ctrl+E | Jump to end of line |
Ctrl+K | Cut to end of line |
Ctrl+U | Cut to beginning of line |
Ctrl+W | Cut word backward |
Ctrl+Y | Paste cut text |
View Switching
Section titled “View Switching”| Shortcut | Action |
|---|---|
F2 | Query/history view |
F3 | Table view |
F4 | Trace view |
F5 | AI conversation view |
F6 | Toggle column types |
Navigation Mode (Tables)
Section titled “Navigation Mode (Tables)”| Shortcut | Action |
|---|---|
j / k | Scroll line down/up |
d / u | Scroll half page |
g / G | Jump to top/bottom |
< / > | Scroll left/right (10 cols) |
0 / $ | First/last column |
Next Steps
Section titled “Next Steps”- AI Features - Configure AI providers
- Parquet Support - Work with Parquet files
- Configuration - Full configuration reference