The document describes the schema and data manipulation language (DML) for Cassandra. It outlines how to create, modify, and delete keyspaces, tables, indexes, materialized views, users and more. It also covers CRUD operations for inserting, updating, deleting and querying data in Cassandra tables.
The document describes the schema and data manipulation language (DML) for Cassandra. It outlines how to create, modify, and delete keyspaces, tables, indexes, materialized views, users and more. It also covers CRUD operations for inserting, updating, deleting and querying data in Cassandra tables.
The document describes the schema and data manipulation language (DML) for Cassandra. It outlines how to create, modify, and delete keyspaces, tables, indexes, materialized views, users and more. It also covers CRUD operations for inserting, updating, deleting and querying data in Cassandra tables.
CREATE KEYSPACE | SCHEMA IF NOT EXISTS keyspace_name TYPE | KEYSPACE | MATERIALIZED VIEW]; WITH REPLICATION = map AND DURABLE_WRITES = true | false; M OD I F I C A R EL EM E N TOS
map = {'class': 'strategy_class',
'replication_factor': replication_factor, ALTER KEYSPACE keyspace_name 'key1': 'value1', ...} WITH REPLICATION = map;
USE keyspace_name; ALTER TABLE [keyspace_name.]table_name
[ALTER COLUMN column_name TYPE cql_type] | DESCRIBE keyspace_name; [ADD (column_definition [, column_definition]*)] | [DROP (column_definition [, column_definition]*)] | CRUD [RENAME column_name TO column_name] CREATE TABLE [IF NOT EXISTS] [WITH table_properties]; [keyspace_name.]table_name ( column_definition [, column_definition]* table_properties = table_options PRIMARY KEY (column_name [,column_name]*) CONSULTAS [WITH table_options | CLUSTERING ORDER BY (column_name order)]); SELECT [JSON] column_list | [DISTINCT] partition_key [AS output_name] table_options = {'comment': 'text', 'read_repair_chance': value, FROM [keyspace_name.]table_name 'dclocal_read_repair_chance': value, 'gc_grace_seconds': value, [WHERE [primary_key_conditions] [AND index_conditions] 'bloom_filter_fp_chance': value, 'caching': caching_properties, [GROUP BY column_name [, column_name] 'compaction': compaction_properties, [ORDER BY PK_column_name [ASC | DESC] [, ...]] 'compression': compression_properties, [LIMIT n | PER PARTITION LIMIT n] 'default_time_to_live': value, 'speculative_retry': value, [ALLOW FILTERING]; 'index_interval': value, 'min_index_interval': value, 'max_index_interval': value, 'crc_check_chance': value, CREAR INDICES /VISTA MATERI ALIZADA/BATCH 'extensions': '{'key1': 'value1', ...}'} CREATE INDEX IF NOT EXISTS index_name ON INSERT INTO keyspace_name.table_name (identifier[, [keyspace_name.]table_name (KEYS (column_name)) column_name]*) USING class_name WITH OPTIONS = map VALUES (value [,value]*) [IF NOT EXISTS USING option [AND option]*]; class_name = 'index_class_name' | 'org.apache.cassandra.index.sasi.SASIIndex'; option = USING TIMESTAMP timestamp_value | USING TTL time_value CREATE MATERIALIZED VIEW [IF NOT EXISTS] view_name AS SELECT select_statement UPDATE [keyspace_name.]table_name PRIMARY KEY (primary_key) [USING TTL time_value | USING TIMESTAMP timestamp_value] WITH table_options SET assignment [, assignment]* WHERE row_specification BEGIN BATCH [USING TIMESTAMP timestamp_value] [IF EXISTS | IF condition [AND condition]]; modification_statement (; modification_statement)* APPLY BATCH condition = column_name operator value modification_statement: insert_statement, update_statement, DELETE [column_name [, column_name]* | column_name [term ]] delete_statement. FROM [keyspace_name.]table_name [USING TIMESTAMP timestamp_value] Tipos de datos: WHERE row_specification - Texto: text [IF EXISTS | IF condition [AND condition]]; - Número Entero: int - Número de Punto Flotante: float, double term = operator value - Número Decimal: decimal - Booleano: boolean C R EA R D I S P A R A D OR ES - Fecha/Hora: timestamp, date, time CREATE TRIGGER IF NOT EXISTS trigger_name ON table_name - Identificador Único (UUID) USING 'java_class'; - Contador: counter - Colecciones: C R EA R US UA R I OS o Mapa: map<key_type, value_type> CREATE USER IF NOT EXISTS user_name WITH PASSWORD 'pass' o Lista: list<element_type> NOSUPERUSER | SUPERUSER; o Conjunto: set<element_type> C R EA R TI P OS D EF I NI D OS P OR E L U S UA R I O o Tuple: tuple<type1, type2, ...> - User-Defined Type (UDT): frozen<udt_name> CREATE TYPE IF NOT EXISTS keyspace_name.type_name (field - Time-To-Live (TTL): int [,field]*); - Bloque de Bytes (Blob): blob