cql

Cassandra 2 - list existing indexes with CQL 3

时光毁灭记忆、已成空白 提交于 2019-12-18 12:29:57
问题 Is there a CQL query to list all existing indexes for particular key space, or column family? 回答1: You can retrieve primary keys and secondary indexes using the system keyspace: SELECT column_name, index_name, index_options, index_type, component_index FROM system.schema_columns WHERE keyspace_name='samplekp'AND columnfamily_name='sampletable'; Taking, for example, the following table declaration: CREATE TABLE sampletable ( key text, date timestamp, value1 text, value2 text, PRIMARY KEY(key,

Cassandra 2 - list existing indexes with CQL 3

孤街醉人 提交于 2019-12-18 12:28:53
问题 Is there a CQL query to list all existing indexes for particular key space, or column family? 回答1: You can retrieve primary keys and secondary indexes using the system keyspace: SELECT column_name, index_name, index_options, index_type, component_index FROM system.schema_columns WHERE keyspace_name='samplekp'AND columnfamily_name='sampletable'; Taking, for example, the following table declaration: CREATE TABLE sampletable ( key text, date timestamp, value1 text, value2 text, PRIMARY KEY(key,

Cassandra Delete by Secondary Index or By Allowing Filtering

感情迁移 提交于 2019-12-18 12:19:20
问题 I’m trying to delete by a secondary index or column key in a table. I'm not concerned with performance as this will be an unusual query. Not sure if it’s possible? E.g.: CREATE TABLE user_range ( id int, name text, end int, start int, PRIMARY KEY (id, name) ) cqlsh> select * from dat.user_range where id=774516966; id | name | end | start -----------+-----------+-----+------- 774516966 | 0 - 499 | 499 | 0 774516966 | 500 - 999 | 999 | 500 I can: cqlsh> select * from dat.user_range where name=

cassandra, select via a non primary key

六眼飞鱼酱① 提交于 2019-12-18 12:18:20
问题 I'm new with cassandra and I met a problem. I created a keyspace demodb and a table users. This table got 3 columns: id (int and primary key), firstname (varchar), name (varchar). this request send me the good result: SELECT * FROM demodb.users WHERE id = 3; but this one: SELECT * FROM demodb.users WHERE firstname = 'francois'; doesn't work and I get the following error message: InvalidRequest: code=2200 [Invalid query] message="No secondary indexes on the restricted columns support the

How to get current timestamp with CQL while using Command Line?

回眸只為那壹抹淺笑 提交于 2019-12-18 11:37:53
问题 I am trying to insert into my CQL table from the command line. I am able to insert everything. But I am wondering if I have a timestamp column, then how can I insert into timestamp column from the command line? Basically, I want to insert current timestamp whenever I am inserting into my CQL table - Currently, I am hardcoding the timestamp whenever I am inserting into my below CQL table - CREATE TABLE TEST (ID TEXT, NAME TEXT, VALUE TEXT, LAST_MODIFIED_DATE TIMESTAMP, PRIMARY KEY (ID));

How to auto generate uuid in cassandra CQL 3 command line

你说的曾经没有我的故事 提交于 2019-12-18 10:59:09
问题 Just learning cassandra, is there a way to insert a UUID using CQL, ie create table stuff (uid uuid primary key, name varchar); insert into stuff (name) values('my name'); // fails insert into stuff (uid, name) values(1, 'my name'); // fails Can you do something like insert into stuff (uid, name) values(nextuid(), 'my name'); 回答1: You can with time uuids (type 1 UUID) using the now() function e.g. insert into stuff (uid, name) values(now(), 'my name'); Works with uid or timeuuid. It generates

How to batch select data from Cassandra effectively?

醉酒当歌 提交于 2019-12-18 05:25:32
问题 I know Cassandra doesn't support batch query, and it also doesn't recommend to use IN , because it can degrade performance. But I have to get the data by id, for example: select * from visit where id in ([visit_id array]) desc table: CREATE TABLE visit ( enterprise_id int, id text, ........ PRIMARY KEY (enterprise_id, id) The array maybe has thousands of elements. Is there any way can make it effectively? 回答1: Large In query create GC pauses and heap pressure that leads to overall slower

CQL: Unable to Null Check in “Where” Clause

感情迁移 提交于 2019-12-18 04:54:20
问题 Try to return all rows where a specific field is null or not null. select * from ADDRESS where addr1 = null; or select * from ADDRESS where addr1 = 'NULL'; addr1 can be a boolean or text field. I've tried != null , is null , <> null , and isnull(addr1, 'NULL') but I get no viable alternative at input '=' or no index columns present in by-columns clause with "equals' operator" Using Cassandra 1.1.1 & Java 1.7_05 回答1: CQL doesn't have the concept of NULL (yet- see CASSANDRA-3783). The right

Cassandra UPDATE primary key value

萝らか妹 提交于 2019-12-18 03:15:27
问题 I understand that this is not possible using an UPDATE. What I would like to do instead, is migrate all rows with say PK=0 to new rows where PK=1. Are there any simple ways of achieving this? 回答1: For a relatively simple way, you could always do a quick COPY TO/FROM in cqlsh. Let's say that I have a column family (table) called "emp" for employees. CREATE TABLE stackoverflow.emp ( id int PRIMARY KEY, fname text, lname text, role text ) And for the purposes of this example, I have one row in

Difference between Thrift and CQL 3 Columns/Rows

痴心易碎 提交于 2019-12-18 03:00:24
问题 At the Cassandra Summit, it was mentioned that Thrift and CQL 3 have subtle differences in their definitions of columns and rows. The Google hasn't helped me understand this difference. The only information I can find is that the metadata is different, and as such, I shouldn't mix thrift and CQL. What is the subtle difference (I've read a bit about metadata representations...)? in what way does it break the compatibility? Why is the change better? I'm happy to read any docs that will help me,