Cassandra
1. windows 安裝
1.1 下載Cassandra
http://cassandra.apache.org/
解壓縮下在的放到 C:\Cassandra
1.2 修改cassandra.yaml
data_file_directories:
-C:\Cassandra\data
commitlog_directory: C:\Cassandra\commitlog
saved_caches_directory: C:\Cassandra\saved_caches
1.3 安裝JDK
下載安裝jdk http://www.oracle.com/technetwork/java/javase/downloads/index.html
安裝完後在環境變數的地方新增 名稱:JAVA_HOME 變數值:C:\Program Files\Java\jre1.8.0_101
1.4 執行Cassandra
cd C:\cassandra\bin 執行 cassandra.bat
2. 基本CRUD
2.1 CREATE A KEYSPACE AND TABLE
--CREATE KEYSPACE
CREATE KEYSPACE CassandraDB01 WITH replication = {
'class': 'SimpleStrategy',
'replication_factor': '1'
};
--CREATE TABLE
CREATE TABLE users (
firstname text,
lastname text,
age int,
email text,
city text,
PRIMARY KEY (lastname)
);
2.2 INSERT RECORDS
INSERT INTO users (firstname, lastname, age, email, city) VALUES ('John', 'Smith', 46, '[email protected]', 'Sacramento');
INSERT INTO users (firstname, lastname, age, email, city) VALUES ('Jane', 'Doe', 36, '[email protected]', 'Beverly Hills');
INSERT INTO users (firstname, lastname, age, email, city) VALUES ('Rob', 'Byrne', 24, '[email protected]', 'San Diego');
2.3 UPDATE AND DELETE RECORDS
UPDATE users SET city= 'San Jose' WHERE lastname= 'Doe';
DELETE FROM cassandradb01.users WHERE lastname='Smith';
2.4 SELECT RECORDS
select * from users where lastname= 'Doe'