1. 显示存在的数据库
describe keyspaces;
CQL数据库叫keyspace键空间
其中metro是我们自己建的
2.创建数据库
CREATE KEYSPACE IF NOT EXISTS Metros WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor': 3 };
- 策略class
- SimpleStrategy:简单策略,在一个数据中心的情况下使用
- NetworkTopologyStrategy:网络拓扑策略,用于多个数据中心
- 复制因子replication_factor:副本数
- 持久写入属性:durable_write:boolean值,默认true
3.使用数据库
USE Metros;
4. 建表
create table lines(color text, name text, number text, route_name text, primary key(color));
5. 插入
insert into lines JSON ' { "color": "#F58F53", "name": "Tramway 3A", "number": "3A", "route_name": "PONT GARIGLIANO - HOP G.POMPIDOU <-> PORTE DE VINCENNES" }';
CQL命令
最新推荐文章于 2024-07-14 10:59:34 发布