Grammar diagrams YCQL
alter_table alter_table ::= ALTER TABLE table_name
{ ADD { column_name column_type } [ , ... ]
| DROP { column_name [ , ... ] }
| RENAME { column_name TO column_name } [ , ... ]
| WITH { property_name = property_literal }
[ AND ... ] } [ ... ]
ALTER TABLE table_name ADD , column_name column_type DROP , column_name RENAME , column_name TO column_name WITH AND property_name = property_literal
column_type column_type ::= '<type>'
<type>
create_index create_index :: = CREATE [ UNIQUE ] [ DEFERRED ] INDEX
[ IF NOT EXISTS ] index_name ON table_name (
partition_key_columns , [ clustering_key_columns ] )
[ covering_columns ] [ index_properties ]
[ WHERE index_predicate ]
CREATE UNIQUE DEFERRED INDEX IF NOT EXISTS index_name ON table_name ( partition_key_columns , clustering_key_columns ) covering_columns index_properties WHERE index_predicate
partition_key_columns partition_key_columns ::= index_column | ( index_column [ , ... ] )
index_column ( , index_column )
clustering_key_columns clustering_key_columns ::= index_column [ , ... ]
, index_column
index_properties index_properties ::= WITH
{ property_name = property_literal
| CLUSTERING ORDER BY (
{ index_column [ ASC | DESC ] } [ , ... ] ) }
[ AND ... ]
WITH AND property_name = property_literal CLUSTERING ORDER BY ( , index_column ASC DESC )
index_column index_column ::= column_name | jsonb_attribute
column_name jsonb_attribute
jsonb_attribute jsonb_attribute ::= column_name [ -> ''attribute_name'' [ ... ] ] ->>
''attribute_name''
column_name -> 'attribute_name' ->> 'attribute_name'
covering_columns covering_columns ::= { COVERING | INCLUDE } ( column_name [ , ... ] )
COVERING INCLUDE ( , column_name )
index_predicate index_predicate ::= where_expression
where_expression
create_keyspace create_keyspace ::= CREATE { KEYSPACE | SCHEMA } [ IF NOT EXISTS ]
keyspace_name keyspace_properties
CREATE KEYSPACE SCHEMA IF NOT EXISTS keyspace_name keyspace_properties
keyspace_properties keyspace_properties ::= [ WITH REPLICATION = { keyspace_property
[ , ... ] } ]
[ AND DURABLE_WRITES = { 'true' | 'false' } ]
WITH REPLICATION = { , keyspace_property } AND DURABLE_WRITES = true false
keyspace_property keyspace_property ::= property_name = property_literal
property_name = property_literal
create_table create_table ::= CREATE TABLE [ IF NOT EXISTS ] table_name (
table_schema ) [ table_properties ]
CREATE TABLE IF NOT EXISTS table_name ( table_schema ) table_properties
table_schema table_schema ::= { column_name column_type
{ PRIMARY KEY | STATIC } [ ... ]
| PRIMARY KEY ( ( column_name [ , ... ] )
[ , column_name [ ... ] ] ) } [ , ... ]
, column_name column_type PRIMARY KEY STATIC PRIMARY KEY ( ( , column_name ) , column_name )
table_properties table_properties ::= WITH
{ property_name = property_literal
| CLUSTERING ORDER BY (
{ column_name [ ASC | DESC ] } [ , ... ] )
| COMPACT STORAGE } [ AND ... ]
WITH AND property_name = property_literal CLUSTERING ORDER BY ( , column_name ASC DESC ) COMPACT STORAGE
create_type create_type ::= CREATE TYPE [ IF NOT EXISTS ] type_name (
{ field_name field_type } [ , ... ] )
CREATE TYPE IF NOT EXISTS type_name ( , field_name field_type )
field_type field_type ::= '<type>'
<type>
drop_keyspace drop_keyspace ::= DROP { KEYSPACE | SCHEMA } [ IF EXISTS ]
keyspace_name
DROP KEYSPACE SCHEMA IF EXISTS keyspace_name
drop_table drop_table ::= DROP TABLE [ IF EXISTS ] table_name
DROP TABLE IF EXISTS table_name
drop_type drop_type ::= DROP TYPE [ IF EXISTS ] type_name
DROP TYPE IF EXISTS type_name
use_keyspace use_keyspace ::= USE keyspace_name
USE keyspace_name
delete delete ::= DELETE FROM table_name
[ USING TIMESTAMP timestamp_expression ] WHERE
where_expression [ IF { [ NOT ] EXISTS | if_expression } ]
[ RETURNS STATUS AS ROW ]
DELETE FROM table_name USING TIMESTAMP timestamp_expression WHERE where_expression IF NOT EXISTS if_expression RETURNS STATUS AS ROW
where_expression where_expression ::= { column_name { < | <=
| = | >=
| > | IN
| NOT IN } expression }
[ AND ... ]
AND column_name < <= = >= > IN NOT IN expression
if_expression if_expression ::= { column_name { < | <= | = | >= | > | IN | NOT IN }
expression } [ AND ... ]
AND column_name < <= = >= > IN NOT IN expression
insert insert ::= INSERT INTO table_name ( column_name [ , ... ] ) VALUES (
expression [ , ... ] )
[ IF { [ NOT ] EXISTS | if_expression } ]
[ USING using_expression ]
[ RETURNS STATUS AS ROW ]
INSERT INTO table_name ( , column_name ) VALUES ( , expression ) IF NOT EXISTS if_expression USING using_expression RETURNS STATUS AS ROW
using_expression using_expression ::= ttl_or_timestamp_expression [ AND ... ]
AND ttl_or_timestamp_expression
ttl_or_timestamp_expression ttl_or_timestamp_expression ::= TTL ttl_expression
| TIMESTAMP timestamp_expression
TTL ttl_expression TIMESTAMP timestamp_expression
expression expression ::= '<expression>'
<expression>
select select ::= SELECT [ DISTINCT ] { * | column_name [ , ... ] } FROM
table_name [ WHERE where_expression [ ALLOW FILTERING ] ]
[ IF if_expression ] [ ORDER BY order_expression ]
[ LIMIT limit_expression ] [ OFFSET offset_expression ]
SELECT DISTINCT * , column_name FROM table_name WHERE where_expression ALLOW FILTERING IF if_expression ORDER BY order_expression LIMIT limit_expression OFFSET offset_expression
order_expression order_expression ::= ( { column_name [ ASC | DESC ] } [ , ... ] )
( , column_name ASC DESC )
update update ::= UPDATE table_name [ USING using_expression ] SET assignment
[ , ... ] WHERE where_expression
[ IF { if_expression
| [ NOT ] EXISTS
| if_expression OR [ NOT ] EXISTS } ]
[ RETURNS STATUS AS ROW ]
UPDATE table_name USING using_expression SET , assignment WHERE where_expression IF if_expression NOT EXISTS if_expression OR NOT EXISTS RETURNS STATUS AS ROW
transaction_block transaction_block ::= BEGIN TRANSACTION
{ { insert | update | delete } ; } [ ... ] END
TRANSACTION ;
BEGIN TRANSACTION insert update delete ; END TRANSACTION ;
truncate truncate ::= TRUNCATE [ TABLE ] table_name
TRUNCATE TABLE table_name
assignment assignment ::= column_name = expression
column_name = expression
ttl_expression ttl_expression ::= '<Integer Literal>'
<Integer Literal>
timestamp_expression timestamp_expression ::= '<Integer Literal>'
<Integer Literal>
limit_expression limit_expression ::= '<Integer Literal>'
<Integer Literal>
offset_expression offset_expression ::= '<Integer Literal>'
<Integer Literal>
keyspace_name keyspace_name ::= '<Text Literal>'
<Text Literal>
property_name property_name ::= '<Text Literal>'
<Text Literal>
property_literal property_literal ::= '<Text Literal>'
<Text Literal>
table_name table_name ::= [ keyspace_name . ] '<Text Literal>'
keyspace_name . <Text Literal>
index_name index_name ::= '<Text Literal>'
<Text Literal>
column_name column_name ::= '<Text Literal>'
<Text Literal>
type_name type_name ::= [ keyspace_name . ] '<Text Literal>'
keyspace_name . <Text Literal>
field_name field_name ::= '<Text Literal>'
<Text Literal>
alter_role alter_role ::= ALTER ROLE role_name WITH role_property [ AND ... ]
ALTER ROLE role_name WITH AND role_property
create_role create_role ::= CREATE ROLE [ IF NOT EXISTS ] role_name
[ WITH role_property [ AND ... ] ]
CREATE ROLE IF NOT EXISTS role_name WITH AND role_property
role_property role_property ::= PASSWORD = '<Text Literal>'
| LOGIN = '<Boolean Literal>'
| SUPERUSER = '<Boolean Literal>'
PASSWORD = <Text Literal> LOGIN = <Boolean Literal> SUPERUSER = <Boolean Literal>
drop_role drop_role ::= DROP ROLE [ IF EXISTS ] role_name
DROP ROLE IF EXISTS role_name
grant_role grant_role ::= GRANT role_name TO role_name
GRANT role_name TO role_name
revoke_role revoke_role ::= REVOKE role_name FROM role_name
REVOKE role_name FROM role_name
grant_permission grant_permission ::= GRANT { all_permissions | permission } ON
resource TO role_name
GRANT all_permissions permission ON resource TO role_name
revoke_permission revoke_permission ::= REVOKE { all_permissions | permission } ON
resource FROM role_name
REVOKE all_permissions permission ON resource FROM role_name
all_permissions all_permissions ::= ALL [ PERMISSIONS ]
ALL PERMISSIONS
role_name role_name ::= '<Text Literal>'
<Text Literal>
permission permission ::= { CREATE
| ALTER
| DROP
| SELECT
| MODIFY
| AUTHORIZE
| DESCRIBE
| EXECUTE } [ PERMISSION ]
CREATE ALTER DROP SELECT MODIFY AUTHORIZE DESCRIBE EXECUTE PERMISSION
resource resource ::= ALL { KEYSPACES | ROLES }
| KEYSPACE keyspace_name
| [ TABLE ] table_name
| ROLE role_name
ALL KEYSPACES ROLES KEYSPACE keyspace_name TABLE table_name ROLE role_name
alter_keyspace alter_keyspace ::= ALTER { KEYSPACE | SCHEMA } keyspae_name
keyspace_properties
ALTER KEYSPACE SCHEMA keyspae_name keyspace_properties
explain explain ::= EXPLAIN { select | update | insert | delete }
EXPLAIN select update insert delete