我在SQL世界一個簡單的要求,我想創建卡桑德拉複合柱族
CREATE TABLE event_tracking (
key text,
trackingid timeuuid,
entityId bigint,
entityType text
userid bigint
PRIMARY KEY (key, trackingid)
)
我需要一個CLI命令創建這是我不能做到這一點。我需要通過CLI創建列族豬不能讀取列家族通過cqlsh(杜)
在這裏創造了什麼我嘗試,並沒有工作
create column family event_tracking
... WITH comparator='CompositeType(TimeUUIDType)'
... AND key_validation_class=UTF8Type
... AND default_validation_class = UTF8Type;
1)我不知道爲什麼它的價值列添加到當我看到它在cqlsh
CREATE TABLE event_tracking (
key text,
trackingid timeuuid,
value text,
PRIMARY KEY (key, trackingid)
) WITH COMPACT STORAGE AND
bloom_filter_fp_chance=0.010000 AND
caching='KEYS_ONLY' AND
comment='' AND
dclocal_read_repair_chance=0.000000 AND
gc_grace_seconds=864000 AND
read_repair_chance=0.100000 AND
replicate_on_write='true' AND
populate_io_cache_on_flush='false' AND
compaction={'class': 'SizeTieredCompactionStrategy'} AND
compression={'sstable_compression': 'SnappyCompressor'};
2)我使用asynatax插入行。
OperationResult<CqlResult<Integer, String>> result = keyspace.prepareQuery(CQL3_CF)
.withCql("INSERT INTO event_tracking (key, column1, value) VALUES ("+System.currentTimeMillis()+","+TimeUUIDUtils.getTimeUUID(System.currentTimeMillis())+",'23232323');").execute();
但只要我嘗試添加動態列,它是不能夠識別
OperationResult<CqlResult<Integer, String>> result = keyspace.prepareQuery(CQL3_CF)
.withCql("INSERT INTO event_tracking (key, column1, value, userId, event) VALUES ("+System.currentTimeMillis()+","+TimeUUIDUtils.getTimeUUID(System.currentTimeMillis())+",'23232323', 123455, 'view');").execute();
貌似我無法通過cql3添加動態列
3)如果我嘗試通過cql3添加新列
alter table event_tracking add eventid bigint;
它給了我
Bad Request: Cannot add new column to a compact CF
謝謝Theo。我的意圖是創建列家族以長鍵(System.getCurrentMilliSeconds()),跟蹤id爲uuid並將它們作爲組合鍵,然後將entityid,entitytype,userid和event添加爲動態列。目的是即使我們同時獲得同時請求,我們也可以在同一行記錄事件。我希望我能說得通。 – plzdontkillme
我可以創建CREATE TABLE event_tracking( 關鍵文字, trackingid timeuuid – plzdontkillme