Cassandra的cqlsh操作

  1. 建库
CREATE KEYSPACE twitter WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor': 1};
  1. 建表
CREATE TABLE IF NOT EXISTS twitter.hotels (
id UUID,
name varchar,
address varchar,
primary key(id)
);
  1. 查询
cqlsh> desc keyspaces;

twitter      system         system_distributed  system_schema
system_auth  elastic_admin  system_traces     

cqlsh> use twitter ;
cqlsh:twitter> desc tables;

"_doc"  hotels
cqlsh:twitter> desc table "_doc"; #查看表结构
cqlsh:twitter> select * from hotels ;
#name不是primary key必须加allow filtering
cqlsh:twitter> SELECT * FROM hotels WHERE name='7天' allow filtering;
#使用contains 对list、set集合中的元素进行过滤
cqlsh:twitter> select * from "_doc" where user contains 'Jimmy' allow filtering;
// 使用contains key 对map集合进行过滤
cqlsh:twitter> select * from users where scores contains key 'english' allow filtering;

count查询

select count(location) from surf_chn_mul_hor.surf_chn_mul_hor ;

数量过大查询无效

OperationTimedOut: errors={'127.0.0.1': 'Client request timeout. See Session.execute[_async](timeout)'}, last_host=127.0.0.1
  1. 更新
    where必须为primary key字段
  2. 删除表
drop table radar;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值