Open WALL-E opened 7 years ago
一:创建keyspace CREATE KEYSPACE demo WITH REPLICATION = {'class':'SimpleStrategy','replication_factor':1};
二:查询有哪些keyspace describe keyspaces;
三:选择keyspace use demo;
四:创建表 cqlsh:demo> CREATE TABLE student(id int, s_name varchar, PRIMARY KEY(id));
五:向表中添加数据 cqlsh:demo> INSERT INTO student (id,s_name) VALUES (1,'Naruto'); cqlsh:demo> INSERT INTO student (id,s_name) VALUES (2,'Naruto');
六:查询数据 cqlsh:demo> select from student; cqlsh:demo> select from student where id=2; cqlsh:demo> select * from student where s_name='Sanji'; 查询没有索引的s_name无法查询.需要先创建一个索引: cqlsh:demo> create index on student(s_name);
七:更新数据 cqlsh:demo> update student set s_name='Luffy' where id=1;
八:删除表数据(必须要有where条件) cqlsh:demo> delete from student where id=2;
Installation from RPM packages
Add the Apache repository of Cassandra to /etc/yum.repos.d/cassandra.repo, for example for the latest 3.11 version:
Install Cassandra, accepting the gpg key import prompts:
Start Cassandra (will not start automatically):
download