命令
本主题主要介绍 VectorDB CLI 所支持的命令和相应选项,包括一些示例供您参考。
命令参考
在成功连接 VectorDB Server 后,开始操作数据库。
Database 操作
创建数据库
描述
创建数据库
命令
1create database
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-h | --help | 否 | 查看帮助信息 |
示例
1vectordb-cli > create database -d testdb
2create database 'testdb' success
3vectordb-cli >
查询库列表
描述
列出当前连接下所有的数据库
命令
1list databases
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-h | --help | 否 | 查看帮助信息 |
示例
1vectordb-cli > list databases
2+--------------+
3| databases |
4+==============+
5| testdb |
6+--------------+
7
8vectordb-cli >
删除数据库
描述
删除指定的数据库
命令
1drop database
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-h | --help | 否 | 查看帮助信息 |
示例
1vectordb-cli > drop database -d testdb
2drop database 'testdb' success
3vectordb-cli >
4vectordb-cli > list databases
5no databases found
6vectordb-cli >
Table 操作
创建表
描述
在指定的库中新建一个表
命令
1create table
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定json文件来输入参数,建表需要的json详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个json作为参数来建表,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数
示例1,控制台输入json参数
1vectordb-cli > create table
2
3input create table args, end with ';'
4...
5... {
6... "database": "testdb",
7... "table": "book",
8... "description": "basic test",
9... "replication": 1,
10... "partition": {
11... "partitionType": "HASH",
12... "partitionNum": 3
13... },
14... "enableDynamicField": false,
15... "schema": {
16... "fields": [
17... {
18... "fieldName": "id",
19... "fieldType": "STRING",
20... "primaryKey": true,
21... "partitionKey": true,
22... "autoIncrement": false,
23... "notNull": true
24... },
25... {
26... "fieldName": "bookName",
27... "fieldType": "STRING",
28... "notNull": true
29... },
30... {
31... "fieldName": "author",
32... "fieldType": "STRING"
33... },
34... {
35... "fieldName": "page",
36... "fieldType": "UINT32"
37... },
38... {
39... "fieldName": "content",
40... "fieldType": "TEXT",
41... "notNull": true
42... },
43... {
44... "fieldName": "tags",
45... "fieldType": "ARRAY",
46... "elementType": "STRING",
47... "maxCapacity": 1024
48... },
49... {
50... "fieldName": "vector",
51... "fieldType": "FLOAT_VECTOR",
52... "notNull": true,
53... "dimension": 3
54... }
55... ],
56... "indexes": [
57... {
58... "indexName": "book_name_idx",
59... "field": "bookName",
60... "indexType": "SECONDARY"
61... },
62... {
63... "indexName": "vector_idx",
64... "field": "vector",
65... "indexType": "HNSW",
66... "metricType": "L2",
67... "params": {
68... "M": 32,
69... "efConstruction": 32
70... },
71... "autoBuild": true,
72... "autoBuildPolicy": {
73... "policyType": "ROW_COUNT_INCREMENT",
74... "rowCountIncrement": 10000
75... }
76... },
77... {
78... "indexName": "content_inverted_index",
79... "indexType": "INVERTED",
80... "fields": ["content"],
81... "fieldsIndexAttributes": ["ATTRIBUTE_ANALYZED"],
82... "params": {
83... "analyaer": "DEFAULT_ANALYZER",
84... "parseMode": "COARSE_MODE"
85... }
86... },
87... {
88... "indexName": "title_index",
89... "indexType": "FILTERING",
90... "fields": [
91... {
92... "field": "@SCALAR",
93... "indexStructureType": "BITMAP"
94... },
95... {
96... "field": "title",
97... "indexStructureType": "DEFAULT"
98... }
99... ]
100... }
101... ]
102... }
103... }
104... ;
105create table 'book' success
106vectordb-cli >
示例2,通过指定json文件来输入参数
下面createTable.json中的内容与上面例子中的json一致。
1vectordb-cli > create table -f ./example/table/createTable.json
2create table 'book' success
3vectordb-cli >
4vectordb-cli >
列出所有表
描述
列出指定数据库下所有的表
命令
1list tables
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-h | --help | 否 | 查看帮助信息 |
示例
1vectordb-cli > list tables -d testdb
2+-----------+
3| tables |
4+===========+
5| book |
6+-----------+
7| book2 |
8+-----------+
9
10vectordb-cli >
删除表
描述
删除指定的表
命令
1drop table
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-t | --table | 是 | 表名 |
-h | --help | 否 | 查看帮助信息 |
示例
1vectordb-cli > drop table -d testdb -t book2
2drop table 'book2' success
3vectordb-cli >
4vectordb-cli > list tables -d testdb
5+-----------+
6| tables |
7+===========+
8| book |
9+-----------+
10
11vectordb-cli >
12vectordb-cli >
获取表的统计信息
描述
获取表的统计信息
命令
1stats table
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-t | --table | 是 | 表名 |
-h | --help | 否 | 查看帮助信息 |
示例
1vectordb-cli > stats table -d testdb -t book
2+-------------+---------------------+-------------------+
3| rowCount | memorySizeInByte | diskSizeInByte |
4+=============+=====================+===================+
5| 0 | 2232 | 0 |
6+-------------+---------------------+-------------------+
7
8vectordb-cli >
查询表详情
描述
查询指定表的详情
命令
1describe table
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-t | --table | 是 | 表名 |
-h | --help | 否 | 查看帮助信息 |
示例
1vectordb-cli > describe table -d testdb -t book
2
3 table 'book' description:
4
5 {
6 "database": "testdb",
7 "table": "book",
8 "createTime": "2024-09-14 11:37:57",
9 "description": "basic test",
10 "replication": 1,
11 "partition": {
12 "partitionType": "HASH",
13 "partitionNum": 3
14 },
15 "enableDynamicField": false,
16 "state": "NORMAL",
17 "schema": {
18 "fields": [
19 {
20 "primaryKey": true,
21 "partitionKey": true,
22 "autoIncrement": false,
23 "notNull": true,
24 "fieldName": "id",
25 "fieldType": "STRING"
26 },
27 {
28 "fieldName": "bookName",
29 "fieldType": "STRING",
30 "primaryKey": false,
31 "partitionKey": false,
32 "autoIncrement": false,
33 "notNull": true
34 },
35 {
36 "autoIncrement": false,
37 "notNull": false,
38 "fieldName": "author",
39 "fieldType": "STRING",
40 "primaryKey": false,
41 "partitionKey": false
42 },
43 {
44 "primaryKey": false,
45 "partitionKey": false,
46 "autoIncrement": false,
47 "notNull": false,
48 "fieldName": "page",
49 "fieldType": "UINT32"
50 },
51 {
52 "fieldName": "vector",
53 "fieldType": "FLOAT_VECTOR",
54 "dimension": 3,
55 "primaryKey": false,
56 "partitionKey": false,
57 "autoIncrement": false,
58 "notNull": true
59 }
60 ],
61 "indexes": [
62 {
63 "indexName": "book_name_idx",
64 "indexType": "SECONDARY",
65 "field": "bookName",
66 "state": "NORMAL"
67 },
68 {
69 "indexName": "vector_idx",
70 "indexType": "HNSW",
71 "metricType": "L2",
72 "params": {
73 "M": 32,
74 "efConstruction": 32
75 },
76 "field": "vector",
77 "state": "INVALID"
78 }
79 ]
80 }
81}
82vectordb-cli >
新增表字段
描述
在指定表中新增一个字段,当前仅支持新增标量、向量字段。
命令
1add field
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定读取特定文件中的json,新增字段需要的json详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个json作为参数来新增字段,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数
示例1,控制台输入json参数
1vectordb-cli > add field
2
3input add field args, end with ';'
4...
5... {
6... "database": "testdb",
7... "table": "book",
8... "schema": {
9... "fields": [
10... {
11... "fieldName": "scalar2",
12... "fieldType": "STRING"
13... },
14... {
15... "fieldName": "vector2",
16... "fieldType": "FLOAT_VECTOR",
17... "dimension": 3
18... }
19... ]
20... }
21... }
22... ;
23add field success.
24vectordb-cli >
示例2,通过指定json文件来输入参数
1vectordb-cli > add field -f ./example/table/addField.json
2add field success.
3vectordb-cli >
使用 describe table
检查新增的标量字段。
1vectordb-cli > describe table -d testdb -t book
2
3 table 'book' description:
4
5 {
6 "database": "testdb",
7 "table": "book",
8 ... ...
9 "schema": {
10 "fields": [
11 ... ...
12 {
13 "partitionKey": false,
14 "autoIncrement": false,
15 "notNull": false,
16 "fieldName": "scalar2",
17 "fieldType": "STRING",
18 "primaryKey": false
19 },
20 {
21 "fieldName": "scalar1",
22 "fieldType": "STRING",
23 "primaryKey": false,
24 "partitionKey": false,
25 "autoIncrement": false,
26 "notNull": false
27 }
28 ]
29 ... ...
30 }
31}
32vectordb-cli >
给表添加别名
描述
给指定的表添加别名
命令
1alias table
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-t | --table | 是 | 表名 |
-a | --alias | 是 | 要添加的别名 |
-h | --help | 否 | 查看帮助信息 |
示例
1vectordb-cli > alias table -d testdb -t book -a book_alias
2alias table success.
3vectordb-cli >
4`查看表的详情,aliases中有新增的 book_alias`
5vectordb-cli > describe table -d testdb -t book
6table 'book_segments' description:
7
8 {
9 "database": "testdb",
10 "table": "book",
11 ... ...
12 "enableDynamicField": false,
13 "state": "NORMAL",
14 "aliases": [
15 "book_alias"
16 ],
17 "schema": {
18 "fields": [
19 {
20
21vectordb-cli >
22vectordb-cli >
给表移除别名
描述
给指定的表移除别名
命令
1unalias table
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-t | --table | 是 | 表名 |
-a | --alias | 是 | 要移除的别名 |
-h | --help | 否 | 查看帮助信息 |
示例
1vectordb-cli > unalias table -d testdb -t book -a book_alias
2unalias table success.
3vectordb-cli >
4vectordb-cli >
5vectordb-cli >
Index 操作
查询索引详情
描述
查询指定索引的详情
命令
1describe index
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-t | --table | 是 | 表名 |
-i | --index | 是 | 索引名 |
-h | --help | 否 | 查看帮助信息 |
示例
1vectordb-cli > describe index -d testdb -t book -i vector_idx
2
3 index 'vector_idx' description:
4
5 {
6 "indexName": "vector_idx",
7 "indexType": "HNSW",
8 "metricType": "L2",
9 "params": {
10 "M": 32,
11 "efConstruction": 32
12 },
13 "field": "vector",
14 "state": "INVALID"
15}
删除索引
描述
删除指定索引
命令
1drop index
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-t | --table | 是 | 表名 |
-i | --index | 是 | 索引名 |
-h | --help | 否 | 查看帮助信息 |
示例
1vectordb-cli > drop index -d testdb -t book -i vector_idx
2drop index 'vector_idx' success
3vectordb-cli >
4vectordb-cli > describe index -d testdb -t book -i vector_idx
5desc index 'vector_idx' failed, [Code: 91; Message: Index Not Found; RequestId: 43cb102a-7361-4987-b451-dfe36115f08a]
6vectordb-cli >
7vectordb-cli >
创建索引
描述
为指定表和字段新建索引,当前仅支持新建向量索引。支持同时建立多个索引(针对不同字段)。
命令
1create index
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定读取特定文件中的json,创建索引需要的json详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个json作为参数来创建索引,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数
示例1,控制台输入json参数
1vectordb-cli > create index
2
3input create index args, end with ';'
4...
5... {
6... "database": "testdb",
7... "table": "book",
8... "indexes": [
9... {
10... "field": "vector",
11... "indexName": "vector_idx",
12... "indexType": "HNSW",
13... "metricType": "L2",
14... "params": {
15... "M": 32,
16... "efConstruction": 200
17... }
18...
19... }
20... ]
21... }
22... ;
23create indexes for table 'book' success
24vectordb-cli >
25`查看新建的索引`
26vectordb-cli >
27vectordb-cli > describe index -d testdb -t book -i vector_idx
28
29 index 'vector_idx' description:
30
31 {
32 "indexName": "vector_idx",
33 "indexType": "HNSW",
34 "metricType": "L2",
35 "params": {
36 "M": 32,
37 "efConstruction": 200
38 },
39 "field": "vector",
40 "state": "INVALID"
41}
42vectordb-cli >
示例2,通过指定json文件来输入参数
1vectordb-cli > create index -f ./example/index/createIndex.json
2create indexes for table 'book' success
3vectordb-cli >
修改索引
描述
修改向量索引信息,目前只支持修改autoBuild属性。
命令
1modify index
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定读取特定文件中的json,修改索引需要的json详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个json 作为参数来修改索引,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数
示例1,控制台输入json参数
1vectordb-cli > modify index
2
3input modify index args, end with ';'
4...
5... {
6... "database": "book",
7... "table": "book_segments",
8... "index": {
9... "indexName": "vector_idx",
10... "autoBuild": true,
11... "autoBuildPolicy": {
12... "policyType": "timing",
13... "timing": "2024-10-01 12:00:00"
14... }
15... }
16... }
17...
18... ;
19modify index 'vector_idx' success
20vectordb-cli >
21vectordb-cli >
22`查看修改后的索引`
23vectordb-cli >
24vectordb-cli > describe index -d testdb -t book -i vector_idx
25
26 index 'vector_idx' description:
27
28 {
29 "indexName": "vector_idx",
30 "indexType": "HNSW",
31 "metricType": "L2",
32 "params": {
33 "M": 32,
34 "efConstruction": 200
35 },
36 "field": "vector",
37 "state": "INVALID",
38 "autoBuild": true,
39 "autoBuildPolicy": {
40 "policyType": "timing",
41 "timing": "2024-10-01 12:00:00"
42 }
43}
44vectordb-cli >
45
示例2,通过指定json文件来输入参数
1vectordb-cli > modify index -f ./example/index/modifyIndex.json
2modify index 'vector_idx' success
3vectordb-cli >
重建索引
描述
重建指定索引,仅支持重建向量索引。
命令
1rebuild index
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-t | --table | 是 | 表名 |
-i | --index | 是 | 索引名 |
-h | --help | 否 | 查看帮助信息 |
示例
1vectordb-cli > rebuild index -d testdb -t book -i vector_idx
2rebuild index 'vector_idx' success
3vectordb-cli >
4`重建索引后,可以看到,索引的状态从 INVALID 转为 BUILDING, 最后转为 NORMAL`
5vectordb-cli >
6vectordb-cli > describe index -d testdb -t book -i vector_idx
7
8 index 'vector_idx' description:
9
10 {
11 "indexName": "vector_idx",
12 "indexType": "HNSW",
13 "metricType": "L2",
14 "params": {
15 "M": 32,
16 "efConstruction": 200
17 },
18 "field": "vector",
19 "state": "BUILDING"
20}
21vectordb-cli >
22vectordb-cli > describe index -d testdb -t book -i vector_idx
23
24 index 'vector_idx' description:
25
26 {
27 "indexName": "vector_idx",
28 "indexType": "HNSW",
29 "metricType": "L2",
30 "params": {
31 "M": 32,
32 "efConstruction": 200
33 },
34 "field": "vector",
35 "state": "NORMAL"
36}
Role 操作
创建角色
描述
创建一个新的角色
命令
1create role
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-r | --role | 是 | 角色名 |
-h | --help | 否 | 查看帮助信息 |
示例
1vectordb-cli > create role -r writable
2create role 'writable' success
3vectordb-cli >
删除角色
描述
删除指定的角色
命令
1drop role
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-r | --role | 是 | 角色名 |
-h | --help | 否 | 查看帮助信息 |
示例
1vectordb-cli > drop role -r writable
2Drop role writable ? (y/N) y
3drop role 'writable' success
4vectordb-cli >
授权角色以权限
描述
将指定的一个或多个权限元组(Privilege Tuple)授权给指定的角色。支持同时授权具体的权限和权限组(Privilege Group)。
命令
1grant role privilege
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定 json 文件来输入参数,需要的 json 详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个 json 作为参数来授权角色以权限,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数 示例 1,控制台输入 json 参数
1vectordb-cli > grant role privilege
2
3input grant role privilage args, end with ';'
4...
5... {
6... "role": "writable",
7... "privilegeTuples": [
8... {
9... "database": "*",
10... "table": "*",
11... "privileges": ["QUERY", "SELECT", "SEARCH"]
12... },
13... {
14... "database": "testdb",
15... "table": "book",
16... "privileges": ["TABLE_CONTROL", "TABLE_READWRITE"]
17... }
18... ]
19... }
20... ;
21grant role 'writable' privileges success
22vectordb-cli >
示例 2,通过指定 json 文件来输入参数
下面 grantRolePrivileges.json 中的内容与上面例子中的 json 一致。
1vectordb-cli > grant role privilege -f ./example/role/grantRolePrivileges.json
2grant role 'writable' privileges success
3vectordb-cli >
展示角色的权限
描述
展示指定角色的所有权限,以及被授权到的用户列表
命令
1show role privilege
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-r | --role | 是 | 角色名 |
-h | --help | 否 | 查看帮助信息 |
示例
1vectordb-cli > show role privilege -r writable
2
3 {
4 "privilegeTuples": [
5 {
6 "database": "*",
7 "table": "*",
8 "privileges": [
9 "QUERY",
10 "SELECT",
11 "SEARCH"
12 ]
13 },
14 {
15 "database": "testdb",
16 "table": "book",
17 "privileges": [
18 "CREATE_TABLE",
19 "DROP_TABLE",
20 "SHOW_TABLE",
21 "QUERY",
22 "SELECT",
23 "SEARCH",
24 "INSERT",
25 "UPSERT",
26 "UPDATE",
27 "DELETE",
28 "SET_TTL",
29 "ALTER_TABLE",
30 "CONFIG_TABLE",
31 "CONFIG_INDEX",
32 "BUILD_INDEX",
33 "CDC_ADMIN",
34 "PARTITION",
35 "BULKLOAD",
36 "ALIAS"
37 ]
38 }
39 ]
40}
41vectordb-cli >
回收角色的权限
描述
回收指定角色的指定的一个或多个权限元组(Privilege Tuple)。支持同时回收具体的权限和权限组(Privilege Group)。
命令
1revoke role privilege
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定 json 文件来输入参数,需要的 json 详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个 json 作为参数来回收角色的权限,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数 示例 1,控制台输入 json 参数
1vectordb-cli > revoke role privilege
2
3input revoke role privilage args, end with ';'
4...
5... {
6... "role": "writable",
7... "privilegeTuples": [
8... {
9... "database": "testdb",
10... "table": "book",
11... "privileges": ["TABLE_READWRITE"]
12... }
13... ]
14... }
15... ;
16revoke role 'writable' privileges success
17vectordb-cli >
示例 2,通过指定 json 文件来输入参数
下面 revokeRolePrivileges.json 中的内容与上面例子中的 json 一致。
1vectordb-cli > revoke role privilege -f ./example/role/revokeRolePrivileges.json
2revoke role 'writable' privileges success
3vectordb-cli >
检查角色当前的权限
1vectordb-cli > show role privilege -r writable
2
3 {
4 "privilegeTuples": [
5 {
6 "database": "*",
7 "table": "*",
8 "privileges": [
9 "QUERY",
10 "SELECT",
11 "SEARCH"
12 ]
13 },
14 {
15 "database": "testdb",
16 "table": "book",
17 "privileges": [
18 "CREATE_TABLE",
19 "DROP_TABLE",
20 "SHOW_TABLE",
21 "SET_TTL",
22 "ALTER_TABLE",
23 "CONFIG_TABLE",
24 "CONFIG_INDEX",
25 "BUILD_INDEX",
26 "CDC_ADMIN",
27 "PARTITION",
28 "BULKLOAD",
29 "ALIAS"
30 ]
31 }
32 ]
33}
34vectordb-cli >
根据权限筛选角色
描述
根据指定的一个或多个权限元组(Privilege Tuple)来筛选同时满足这些权限要求的角色。若不指定任何权限,则等价于列出所有角色。
命令
1select role
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定 json 文件来输入参数,需要的 json 详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个 json 作为参数来筛选角色,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数 示例 1,控制台输入 json 参数
1vectordb-cli > select role
2
3input select role args, end with ';'
4...
5... {
6... "privilegeTuples": [
7... {
8... "database": "testdb",
9... "table": "book",
10... "privileges": ["TABLE_CONTROL"]
11... }
12... ]
13... }
14... ;
15
16+-------------+
17| role |
18+=============+
19| ADMIN |
20+-------------+
21| writable |
22+-------------+
23
24vectordb-cli >
25
示例 2,通过指定 json 文件来输入参数
下面 selectRole.json 中的内容与上面例子中的 json 一致。
1vectordb-cli > select role -f ./example/role/selectRole.json
2
3+-------------+
4| role |
5+=============+
6| ADMIN |
7+-------------+
8| writable |
9+-------------+
10
11vectordb-cli >
User 操作
创建用户
描述
创建一个新的用户
命令
1create user
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-u | --user | 是 | 用户名 |
-h | --help | 否 | 查看帮助信息 |
示例1,创建用户成功
1vectordb-cli > create user -u user1
2Enter password for 'user1' :
3Confirm password for 'user1':
4create user 'user1' success
5vectordb-cli >
示例2,错误示范
- 两次输入密码不一致,需要重试
- 空密码,需要重试
- 密码过于简单,创建失败
1vectordb-cli > create user -u user2
2Enter password for 'user2' :
3Confirm password for 'user2':
4Error: Passwords do not match. Please try again.
5Enter password for 'user2' :
6Confirm password for 'user2':
7Error: Empty password. Please try again.
8Enter password for 'user2' :
9Confirm password for 'user2':
10create user 'user2' failed, [Code: 2; Message: Invalid Parameter: parameter 'password' illegal; RequestId: 1a53f38f-af22-49a3-ac97-7b3618d4586b]
11vectordb-cli >
删除用户
描述
删除指定的用户
命令
1drop user
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-u | --user | 是 | 用户名 |
-h | --help | 否 | 查看帮助信息 |
示例
1vectordb-cli > drop user -u user1
2Drop user user1 ? (y/N) y
3drop user 'user1' success
4vectordb-cli >
修改用户密码
描述
修改指定用户的密码。密码修改规则如下:
- 每个用户可以修改自身的密码,需要验证旧密码,旧密码可以从Authrization头获得。
- 若root用户具备PASSWORD权限,那么root用户可以直接修改其它非root用户的密码,无需验证指定用户的旧密码(相当于直接重置非root用户的密码)。 故,在请求体中,始终无需指定目标用户的旧密码。
- 如果用户修改了自身的密码,需要重新登录 VectorDB-cli。
命令
1change user password
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-u | --user | 是 | 用户名 |
-h | --help | 否 | 查看帮助信息 |
示例1,修改密码成功
1vectordb-cli > change user password -u user1
2Enter password for 'user1' :
3Confirm password for 'user1':
4change user 'user1' password success
5vectordb-cli >
示例2,修改自身密码成功,需要重新登录
1vectordb-cli > change user password -u user1
2Enter password for 'user1' :
3Confirm password for 'user1':
4change user 'user1' password success
5Please restart vectordb-cli with new password for 'user1'
6[bin]$
示例3,错误示范
- 两次输入密码不一致,需要重试
- 空密码,需要重试
- 密码过于简单,修改失败
1vectordb-cli > change user password -u user1
2Enter password for 'user1' :
3Confirm password for 'user1':
4Error: Passwords do not match. Please try again.
5Enter password for 'user1' :
6Confirm password for 'user1':
7Error: Empty password. Please try again.
8Enter password for 'user1' :
9Confirm password for 'user1':
10change user 'user1' password failed, [Code: 2; Message: Invalid Parameter: parameter 'newPassword' illegal; RequestId: 4e49a346-ee4b-46a6-81db-5734585caf79]
11vectordb-cli >
授权用户以角色
描述
将指定的的一个或多个角色授权给指定的用户,完成授权之后,该用户自动获得这些角色具备的所有权限
命令
1grant user role
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-u | --user | 是 | 用户名 |
-r | --role | 是 | 角色名列表 |
-h | --help | 否 | 查看帮助信息 |
示例
1vectordb-cli > grant user role -u user1 -r writable -r readable
2grant user 'user1' roles success
3vectordb-cli >
回收用户的角色
描述
回收指定用户的指定的一个或多个角色,完成回收之后,该用户不再具备由这些角色提供的权限。需要注意的是,用户可能具备独立权限
命令
1revoke user role
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-u | --user | 是 | 用户名 |
-r | --role | 是 | 角色名列表 |
-h | --help | 否 | 查看帮助信息 |
示例
1vectordb-cli > revoke user role -u user1 -r readable
2revoke user 'user1' roles success
3vectordb-cli >
授权用户以权限
描述
将指定的一个或多个权限元组(Privilege Tuple)授权给指定的用户。支持同时授权具体的权限和权限组(Privilege Group)。
命令
1grant user privilege
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定 json 文件来输入参数,需要的 json 详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个 json 作为参数来授权用户以权限,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数 示例 1,控制台输入 json 参数
1vectordb-cli > grant user privilege
2
3input grant user privilage args, end with ';'
4...
5... {
6... "username": "user1",
7... "privilegeTuples": [
8... {
9... "database": "*",
10... "table": "*",
11... "privileges": ["QUERY", "SELECT", "SEARCH"]
12... },
13... {
14... "database": "testdb",
15... "table": "book",
16... "privileges": ["TABLE_CONTROL", "TABLE_READWRITE"]
17... }
18... ]
19... }
20... ;
21grant user 'user1' privileges success
22vectordb-cli >
23vectordb-cli >
示例 2,通过指定 json 文件来输入参数
下面 grantUserPrivileges.json 中的内容与上面例子中的 json 一致。
1vectordb-cli >
2vectordb-cli > grant user privilege -f ./example/user/grantUserPrivileges.json
3grant user 'user1' privileges success
4vectordb-cli >
回收用户的权限
描述
回收指定用户的指定的一个或多个权限元组(Privilege Tuple)。支持同时回收具体的权限和权限组(Privilege Group)
命令
1revoke role privilege
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定 json 文件来输入参数,需要的 json 详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个 json 作为参数来回收用户的权限,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数 示例 1,控制台输入 json 参数
1vectordb-cli > revoke user privilege
2
3input revoke user privilage args, end with ';'
4...
5... {
6... "username": "user1",
7... "privilegeTuples": [
8... {
9... "database": "testdb",
10... "table": "book",
11... "privileges": ["TABLE_READWRITE"]
12... }
13... ]
14... }
15... ;
16revoke user 'user1' privileges success
17vectordb-cli >
示例 2,通过指定 json 文件来输入参数
下面 revokeUserPrivileges.json 中的内容与上面例子中的 json 一致。
1vectordb-cli > revoke user privilege -f ./example/user/revokeUserPrivileges.json
2revoke user 'user1' privileges success
3vectordb-cli >
展示用户的权限
描述
展示指定用户的所有权限,以及角色
命令
1show user privilege
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-u | --user | 是 | 用户名 |
-h | --help | 否 | 查看帮助信息 |
示例
1vectordb-cli > show user privilege -u user1
2
3 {
4 "roles": [
5 {
6 "role": "readable"
7 },
8 {
9 "role": "writable",
10 "privilegeTuples": [
11 {
12 "database": "*",
13 "table": "*",
14 "privileges": [
15 "QUERY",
16 "SELECT",
17 "SEARCH"
18 ]
19 },
20 {
21 "database": "testdb",
22 "table": "book",
23 "privileges": [
24 "CREATE_TABLE",
25 "DROP_TABLE",
26 "SHOW_TABLE",
27 "SET_TTL",
28 "ALTER_TABLE",
29 "CONFIG_TABLE",
30 "CONFIG_INDEX",
31 "BUILD_INDEX",
32 "CDC_ADMIN",
33 "PARTITION",
34 "BULKLOAD",
35 "ALIAS"
36 ]
37 }
38 ]
39 }
40 ],
41 "privilegeTuples": [
42 {
43 "database": "*",
44 "table": "*",
45 "privileges": [
46 "USAGE"
47 ]
48 }
49 ]
50}
51vectordb-cli >
根据权限筛选用户
描述
根据指定的一个或多个权限元组(Privilege Tuple)和/或一个或多个角色来筛选同时满足这些权限要求的用户。权限元组和角色都是可选的,若不指定任何权限和任何角色,则等价于列出所有用户。
命令
1select user
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定 json 文件来输入参数,需要的 json 详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个 json 作为参数来筛选用户,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数 示例 1,控制台输入 json 参数
1vectordb-cli > select user
2
3input select user args, end with ';'
4...
5... {
6... "roles": ["writable"],
7... "privilegeTuples": [
8... {
9... "database": "testdb",
10... "table": "book",
11... "privileges": ["TABLE_CONTROL"]
12... }
13... ]
14... }
15... ;
16
17+----------+
18| user |
19+==========+
20| user1 |
21+----------+
22
23vectordb-cli >
示例 2,通过指定 json 文件来输入参数
下面 selectUser.json 中的内容与上面例子中的 json 一致。
1vectordb-cli > select user -f ./example/user/selectUser.json
2
3+----------+
4| user |
5+==========+
6| user1 |
7+----------+
8
9vectordb-cli >