cassandra-cqlsh基本操作
来源:互联网 发布:岳阳网络车招骋公司 编辑:程序博客网 时间:2024/06/06 12:31
Cassandra CQL操作基础
CQL是Cassandra Query Language的缩写,目前作为Cassandra默认并且主要的交互接口。CQL和SQL比较类似,主要的区别是Cassandra不支持join或子查询。
在执行操作之前,首先打开命令行进入Cassandra安装目录下的bin文件夹,执行cqlsh,如果不成功可能你的cassandra没有开启,要先在bin目录下开启,即输入cassandra即可,在开启后需要在另开启一个命令行窗口执行cql。
一:创建keyspace
cqlsh> CREATE KEYSPACE IFNOT EXISTS demo1 WITH REPLICATION = {'class':'SimpleStrategy','replication_factor':1};
二:查询有哪些keyspace
describe keyspaces;
可以看到已经成功创建了名为demo1的keyspace,然后开始使用。
三:选择keyspace
use demo1;(一定要切记加上;否则会一直出现...语句无法终止)
四:创建表
cqlsh:demo1> CREATE TABLE student(
... id int,
... s_name varchar,
... PRIMARY KEY(id));
五:向表中添加数据
cqlsh:demo1> INSERT INTO student (id,s_name) VALUES (1,'Naruto');
cqlsh:demo1> INSERT INTO student (id,s_name) VALUES (2,'Naruto');
六:查询数据
cqlsh:demo1> select * from student;
cqlsh:demo1> select * from student where id=2;根据主键查询
cqlsh:demo1> select * from student where s_name='Sanji';
查询没有索引的s_name无法查询.需要先创建一个索引:
cqlsh:demo1> create index on student(s_name);
七:更新数据
cqlsh:demo1> update student set s_name='Luffy' where id=1;
八:删除表数据(必须要有where条件)
cqlsh:demo1> delete from student where id=3;
- cassandra-cqlsh基本操作
- cqlsh操作cassandra
- Cassandra-cqlsh基础操作
- 安装 cassandra,使用基本的cqlsh
- cassandra cqlsh代码分析
- Cassandra cqlsh命令大全
- Cassandra 基本操作
- Cassandra工具:cqlsh(the cql shell)
- 在windows环境中配置Cassandra 和 cqlsh 环境
- cassandra简单介绍与基本操作
- Cassandra操作
- Cassandra学习笔记-基本特性与API操作
- Cassandra数据操作 -- cassandra-cli
- Cassandra数据操作 -- CQL
- Cassandra操作入门
- Cassandra命令行操作概述
- cassandra 命令行操作
- Cassandra操作备份
- W10修改注册表显示:无法编辑(键值):写该值的新内容时出错
- 数据结构之红黑树(三)——删除操作
- Please allow Subclipse team to receive anonymous usage statistics for this Eclipse intance
- 和菜鸟一起学linux内核源码之基础准备篇
- Android 开发中我们常使用到的桌面图标的大小
- cassandra-cqlsh基本操作
- Git上传步骤及命令
- websocket实现QQ聊天一之一(服务端编写)
- Structure SOPCKLSTI1(SAPoffice: Description of Imported Object Components)
- android N 拨打电话流程(MO)
- JS的with语句的使用方式
- 微信开发-消息模板回复(java)
- 处理log4j.properties配置详解与实例问题
- Java提供的进制转换