27 Şubat 2023 Pazartesi

Apache Cassandra Query Language - CQL ile DDL

ROLE
Örnek
Şöyle yaparız
CREATE ROLE iot_root_user WITH SUPERUSER = true AND 
                                LOGIN = true AND 
                                PASSWORD = 'password';

LIST roles;

DROP role iot_root_user;

CREATE KEYSPACE iot
    WITH REPLICATION = {
        'class' : 'SimpleStrategy',
        'replication_factor' : 1
        };
KEYSPACE
Örnek
Şöyle yaparız
CREATE KEYSPACE iot
    WITH REPLICATION = {
        'class' : 'SimpleStrategy',
        'replication_factor' : 1
        };


DESCRIBE KEYSPACES;

DESCRIBE KEYSPACE iot;

DROP KEYSPACE iot;

USE iot;
CREATE
Örnek
Şöyle yaparız
CREATE COLUMNFAMILY sensor_events (
                    account_name text,
                    device_id UUID,
                    event_id UUID,
                    event_date date,
                    closest_devices_ip set<inet>,
                    tempratures list<int>,
                    tags map<text,text>,
                    latitude float,
                    longitude float,
                    humidity  int,
                    event_time time,
                    PRIMARY KEY((account_name,device_id), event_id, event_date)
);

DESCRIBE COLUMNFAMILIES;

DESCRIBE COLUMNFAMILY sensor_events;

ALTER COLUMNFAMILY sensor_events ADD pressure int;
TRUNCATE
Örnek
Şöyle yaparız
TRUNCATE COLUMNFAMILY sensor_events;

Hiç yorum yok:

Yorum Gönder