1. CQL客户端链接

bin/cqlsh ip username password

2.

(1)建立keyspace语句,keyspace类似于 mysql 中的数据库,一个数据库中可以有很多表;

CREATE KEYSPACE mykeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy','replication_factor' : 2 } ,replication_factor 表示 数据被复制几份

(2)建表语句:

CREATE TABLE task ( row_split text, column_split text, username text, parent_user text, priority int, url text,status int, is_dir boolean, channel_code text, is_multilayer boolean, action_type int, create_time bigint, finish_time bigint, id text, subtask_result text, reason text, retry_time int, PRIMARY KEY (row_split, column_split) ) ;  primary key 的第一个元素是rowkey,第二个元素的是cluster key;
 
(3)建索引语句:
create index task_status on task(status);  cassandra的索引不支持范围查找,类似于 位图索引 或者 哈希索引,支持 = 操作,不支持< 或 > 之类的范围查找;
 
(4)查询语句,
select * from task where status=2;
注意,cassandra where 子句里面的,除了rowkey以外,其他字段如果要使用 = 操作,必须建立二级索引,而且cassandra里面的二级索引 不支持范围查询,类似于位图索引,不同于 BTREE索引;
 
(5)删除语句,
单独删除某个column 或者 某行;
delete column1,column2 from table where rowkey = 'xxxx' 
or 
delete column1,column2 from table where rowkey in ('x','xx','xxx'...)
其中where子句是不能省略的。
 
(6)删除表中的所有数据
如果要想实现 类似 mysql中 delete from table的效果,可以使用truncate;
 
truncate table

cassandra CQL 常用操作的更多相关文章

  1. 【三】用Markdown写blog的常用操作

    本系列有五篇:分别是 [一]Ubuntu14.04+Jekyll+Github Pages搭建静态博客:主要是安装方面 [二]jekyll 的使用 :主要是jekyll的配置 [三]Markdown+ ...

  2. php模拟数据库常用操作效果

    test.php <?php header("Content-type:text/html;charset='utf8'"); error_reporting(E_ALL); ...

  3. Mac OS X常用操作入门指南

    前两天入手一个Macbook air,在装软件过程中摸索了一些基本操作,现就常用操作进行总结, 1关于触控板: 按下(不区分左右)            =鼠标左键 control+按下        ...

  4. mysql常用操作语句

    mysql常用操作语句 1.mysql -u root -p   2.mysql -h localhost -u root -p database_name 2.列出数据库: 1.show datab ...

  5. nodejs配置及cmd常用操作

    一.cmd常用操作 1.返回根目录cd\ 2.返回上层目录cd .. 3.查找当前目录下的所有文件dir 4.查找下层目录cd window 二.nodejs配置 Node.js安装包及源码下载地址为 ...

  6. Oracle常用操作——创建表空间、临时表空间、创建表分区、创建索引、锁表处理

    摘要:Oracle数据库的库表常用操作:创建与添加表空间.临时表空间.创建表分区.创建索引.锁表处理 1.表空间 ■  详细查看表空间使用状况,包括总大小,使用空间,使用率,剩余空间 --详细查看表空 ...

  7. python 异常处理、文件常用操作

    异常处理 http://www.jb51.net/article/95033.htm 文件常用操作 http://www.jb51.net/article/92946.htm

  8. byte数据的常用操作函数[转发]

    /// <summary> /// 本类提供了对byte数据的常用操作函数 /// </summary> public class ByteUtil { ','A','B',' ...

  9. Linux Shell数组常用操作详解

    Linux Shell数组常用操作详解 1数组定义: declare -a 数组名 数组名=(元素1 元素2 元素3 ) declare -a array array=( ) 数组用小括号括起,数组元 ...

随机推荐

  1. String类型,Function类型

    1.String类型:  1)创建String对象:    var str=new String(s);    String(s);    参数:参数 s 是要存储在 String 对象中的值或转换成 ...

  2. python字符串加颜色区别

    1.有时需要显目的区别不同内容,可以改变显目的内容颜色 print("\033[31;1m你好麽,\033[0m我很好..")print("\033[32;1m你好麽,\ ...

  3. bat 命令分行写

    myprog parameter parameter parameter parameter parameter parameter parameter parameter parameter par ...

  4. VS2013: upgrading a Windows Phone 7/8 and Windows 8 apps(转)

    VS2013: upgrading a Windows Phone 7/8 and Windows 8 apps September 17, 2013Windows 8, Windows PhoneJ ...

  5. 解决一道leetcode算法题的曲折过程及引发的思考

    写在前面 本题实际解题过程是 从 40秒 --> 24秒 -->1.5秒 --> 715ms --> 320ms --> 48ms --> 36ms --> ...

  6. cocos2d学习笔记

    doxygen工具 生成cocos2d的api文档 位图字体编辑工具 Glyph Designer http://www.71squared.com/glyphdesigner  收费的 CCLabl ...

  7. spinner下拉框组件

    方法一代码如下: <string-array name="city_name"> <item>浙江</item> <item>上海& ...

  8. 轻松解决Linux安装Eclipse方法

    随着Linux的发展,很多人开始学习Linux系统,你了解Linux系统么?你是Linux系统的应用者么?本文为你详细介绍Linux安装Eclipse,为你在学习Linux安装Eclipse时起一定的 ...

  9. 程序设计入门——C语言 第4周编程练习 2 念整数(5分)

    题目内容: 你的程序要读入一个整数,范围是[-100000,100000].然后,用汉语拼音将这个整数的每一位输出出来. 如输入1234,则输出: yi er san si 注意,每个字的拼音之间有一 ...

  10. javascript模仿php 函数 trim ltrim rtrim (原创)

    javascript模仿php 函数 trim  ltrim rtrim,去除字符串两边空格或其他符号 本文地址:js trim js php trim function trims(){ this. ...