Meta Action

Meta Info Action 用于获取集群内的元数据信息。如数据库列表,表结构等。

数据库列表

Request

1. GET /api/meta/namespaces/<ns_name>/databases

Description

获取所有数据库名称列表,按字母序排列。

Path parameters

无

Query parameters

  • limit

限制返回的结果行数 - offset

分页信息,需要和 limit 一起使用

Request body

无

Response

1. {
2. "msg": "OK",
3. "code": 0,
4. "data": [
5. "db1", "db2", "db3", ...
6. ],
7. "count": 3
8. }
  • data 字段返回数据库名列表。

表列表

Request

1. GET /api/meta/namespaces/<ns_name>/databases/<db_name>/tables

Description

获取指定数据库中的表列表,按字母序排列。

Path parameters

  • <db_name>

指定数据库名称

Query parameters

  • limit

限制返回的结果行数 - offset

分页信息,需要和 limit 一起使用

Request body

无

Response

1. {
2. "msg": "OK",
3. "code": 0,
4. "data": [
5. "tbl1", "tbl2", "tbl3", ...
6. ],
7. "count": 0
8. }
  • data 字段返回表名称列表。

表结构信息

Request

1. GET /api/meta/namespaces/<ns_name>/databases/<db_name>/tables/<tbl_name>/schema

Description

获取指定数据库中,指定表的表结构信息。

Path parameters

  • <db_name>

指定数据库名称 - <tbl_name>

指定表名称

Query parameters

  • with_mv

可选项,如果未指定,默认返回 base 表的表结构。如果指定,则还会返回所有rollup的信息。

Request body

无

Response

1. GET /api/meta/namespaces/default/databases/db1/tables/tbl1/schema

3. {
4. "msg": "success",
5. "code": 0,
6. "data": {
7. "tbl1": {
8. "schema": [{
9. "Field": "k1",
10. "Type": "INT",
11. "Null": "Yes",
12. "Extra": "",
13. "Default": null,
14. "Key": "true"
15. },
16. {
17. "Field": "k2",
18. "Type": "INT",
19. "Null": "Yes",
20. "Extra": "",
21. "Default": null,
22. "Key": "true"
23. }
24. ],
25. "is_base": true
26. }
27. },
28. "count": 0
29. }
1. GET /api/meta/namespaces/default/databases/db1/tables/tbl1/schema?with_mv?=1

3. {
4. "msg": "success",
5. "code": 0,
6. "data": {
7. "tbl1": {
8. "schema": [{
9. "Field": "k1",
10. "Type": "INT",
11. "Null": "Yes",
12. "Extra": "",
13. "Default": null,
14. "Key": "true"
15. },
16. {
17. "Field": "k2",
18. "Type": "INT",
19. "Null": "Yes",
20. "Extra": "",
21. "Default": null,
22. "Key": "true"
23. }
24. ],
25. "is_base": true
26. },
27. "rollup1": {
28. "schema": [{
29. "Field": "k1",
30. "Type": "INT",
31. "Null": "Yes",
32. "Extra": "",
33. "Default": null,
34. "Key": "true"
35. }],
36. "is_base": false
37. }
38. },
39. "count": 0
40. }
  • data 字段返回 base 表或 rollup 表的表结构信息。