Cassandra

Iš Žinynas.
Jump to navigation Jump to search


Prisijungimas[keisti]

cqlsh -u cassandra -p cassandra

Auto prisijungimas, pridedam į failą ~/.cqlshrc

[authentication]
username = cassandra
password = cassandra

DB Sukūrimas/Koregavimas[keisti]

CREATE KEYSPACE IF NOT EXISTS duombaze WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}  AND durable_writes = true;
CREATE KEYSPACE IF NOT EXISTS duombaze2 WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'datacenter1' : 3 };
ALTER KEYSPACE system_auth WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'dc1' : 3, 'dc2' : 2}; 
ALTER KEYSPACE "Excalibur" WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };

Lentelės[keisti]

CREATE TABLE cyclist_name ( id UUID PRIMARY KEY, lastname text, firstname text );
CREATE TABLE person (
   id text,
   name text,
   surname text,
   PRIMARY KEY (id));
CREATE TABLE k1.person (
   id text PRIMARY KEY,
   name text,
   surname text
) WITH bloom_filter_fp_chance = 0.01
   AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
   AND comment = 
   AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
   AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
   AND crc_check_chance = 1.0
   AND dclocal_read_repair_chance = 0.1
   AND default_time_to_live = 0
   AND gc_grace_seconds = 864000
   AND max_index_interval = 2048
   AND memtable_flush_period_in_ms = 0
   AND min_index_interval = 128
   AND read_repair_chance = 0.0
   AND speculative_retry = '99PERCENTILE';
SELECT * FROM person;
DESCRIBE person;

Select/Insert/Update[keisti]

INSERT INTO person (id, name, surname, email) VALUES ('002', 'John', 'Doe', 'john@example.com');
SELECT * from person;
SELECT name FROM person WHERE id='001';
SELECT name FROM person WHERE id IN ('001', '002');
UPDATE cycling.cyclist_career_teams SET teams = teams + {'Team DSB - Ballast Nedam'} WHERE id = 5b6962dd-3f90-4c93-8f61-eabfa4a803e2;
DELETE teams FROM cycling.cyclist_career_teams WHERE id = 5b6962dd-3f90-4c93-8f61-eabfa4a803e2;

Grafiniai administravimo įrankiai[keisti]