语法
CQL。
Datacenter
1 | use system; |
Role / User
创建
1 | CREATE ROLE [IF NOT EXISTS] role_name |
示例
1 | CREATE ROLE IF NOT EXISTS 'root' WITH SUPERUSER = true AND LOGIN = false; |
修改权限
1 | ALTER ROLE role_name |
示例
1 | ALTER ROLE root WITH PASSWORD = 'NewPassword'; |
Key Space
查询
1 | 列出所有 keysapces |
创建
1 | CREATE KEYSPACE [IF NOT EXISTS] keyspace_name |
示例
1 | CREATE KEYSPACE IF NOT EXISTS "trace" WITH REPLICATION = { |
Table
查询
1 | desc <keyspace-name>; |
1 | use <keyspace-name>; |
创建
1 | CREATE TABLE [IF NOT EXISTS] [keyspace_name.]table_name ( |
数据类型参考这里。
删除
1 | DROP TABLE [IF EXISTS] keyspace_name.table_name |
修改
添加列
1 | ALTER TABLE [keyspace_name.] table_name |
示例
1 | ALTER TABLE trace.ranker ADD rid TEXT; |
Query
1 | // 查询一条 |