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. 【20160924】GOCVHelper MFC增强算法(4)

    //string替换     void string_replace(string & strBig, const string & strsrc, const string & ...

  2. 升级PHP

     wget http://down.wdlinux.cn/in/php_up53.shsh php_up53.sh 

  3. String,StringBuffer与StringBuilder的区别??[转]

    String 字符串常量StringBuffer 字符串变量(线程安全)StringBuilder 字符串变量(非线程安全) 简要的说, String 类型和 StringBuffer 类型的主要性能 ...

  4. C++string中用于查找的find系列函数浅析

    总述:      以下所讲的所有的string查找函数,都有唯一的返回类型,那就是size_type,即一个无符号整数(按打印出来的算).若查找成功,返回按查找规则找到的第一个字符或子串的位置:若查找 ...

  5. centos使用yum安装mysql

    参考:http://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/ 1.增加yum数据源 (1.1)从http://dev.mysql.com/dow ...

  6. GIS服务器需求分析

    一. 需求概要 1 边界 核心职责 接收并存储外部各方系统GPS数据 GPS数据实时分发, 轨迹检索   2 流程 GIS客户端向GIS服务器订购 GIS客户端向GIS服务器订购号码(仅有号码这一项业 ...

  7. Trick

    1. var b = a.slice(beginIndex,endIndex); [].slice.call( [] ) Array.prototype.slice.call([]) will cop ...

  8. lamp centos虚拟主机配置

    1.基于不同端口的虚拟主机配置 [root@lamp~]# vi /etc/httpd/conf/httpd.conf Listen 80      #设置监听不同的虚拟主机需要使用的端口 Liste ...

  9. IOS_改变UITextField placeHolder颜色、字体

    http://blog.sina.com.cn/s/blog_671d2e4f0101d90v.html

  10. GIT warning: LF will be replaced by CRLF.

    git config --global core.autocrlf false git config --global core.autocrlf false