Cassandra常用语句

#keysapce操作创建、删除、使用:keyspace就相当于数据库。

[default@Keyspace2] use Keyspace1
... ;
Authenticated to keyspace: Keyspace1
[default@Keyspace1] drop keyspace
... Keyspace1;
fa38adf8-3866-33c3-8f3a-786fad17c7e0
[default@unknown] use Keyspace1;
Keyspace 'Keyspace1' not found.
[default@unknown] create keyspace Keyspace1;
7e015fd3-e83b-36a0-9674-7c443495ca6a
[default@unknown] use Keyspace1;
Authenticated to keyspace: Keyspace1
[default@Keyspace1]


创建列族column family

 column family 就相当于关系数据库中的表。
[plain]  view plain copy print ?
  1. [default@mykeyspace] create column family User;  
  2. 3c077f98-7039-372e-8447-c66c2fb38432  
  3. [default@mykeyspace]  


插入数据

[plain]  view plain copy print ?
  1. [default@mykeyspace] set User[ascii('zhangsan')][ascii('name')]=ascii('zhangsan');  
  2. Value inserted.  
  3. Elapsed time: 48 msec(s).  
  4. [default@mykeyspace] set User[ascii('zhangsan')][ascii('age')]=ascii('18');  
  5. Value inserted.  
  6. Elapsed time: 6.97 msec(s).  
  7. [default@mykeyspace]  

统计数据

[plain]  view plain copy print ?
  1. [default@mykeyspace] count User[ascii('zhangsan')];  
  2. 2 columns  
  3. [default@mykeyspace]  

查询数据

[plain]  view plain copy print ?
  1. default@mykeyspace] get User[ascii('zhangsan')];  
  2. > (column=616765, value=18, timestamp=1363753306031000)  
  3. > (column=6e616d65, value=zhangsan, timestamp=1363753293734000)  
  4. eturned 2 results.  
  5. lapsed time: 21 msec(s).  
  6. default@mykeyspace]  

删除数据

[plain]  view plain copy print ?
  1. [default@mykeyspace] del User[ascii('zhangsan')];  
  2. row removed.  
  3. Elapsed time: 12 msec(s).  
  4. [default@mykeyspace] get User[ascii('zhangsan')];  
  5. Returned 0 results.  
  6. Elapsed time: 1.68 msec(s).  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值