View tables and views in a database¶
View tables and views in a database. Use the returned object name to view fields, table information, or table creation statements.
POST https://moi.matrixorigin.cn/newmoi/meta/db/table
Preparation before calling¶
Prepare your personal access token, workspace ID, and database name. You can first query database to confirm the name.
The examples below use $AI_STUDIO_API_KEY, $WORKSPACE_ID, and $DATABASE.
Request body¶
Replace caller-specific values in the example with actual values.
namestringRequired- The name of the database to be queried.
Request example
curl -X POST "https://moi.matrixorigin.cn/newmoi/meta/db/table" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d "{\"name\":\"$DATABASE\"}"
Successful response¶
{
"code": 200,
"data": {
"db_name": "sales",
"tables": {"tables": [{"name": "orders", "owner": "", "created": "", "rows": 0, "size": 0}], "total": 1},
"views": {"tables": [], "total": 0}
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
integer |
|
|
string |
The name of the database being queried. |
|
array of object or null |
Table list. The service may return |
|
array of object or null |
View list. The service may return |
|
integer |
Number of objects in the table list. |
|
integer |
Number of objects in the view list. |
|
string |
Table name; used to query table information, fields or table creation statements. |
|
string |
View name; used to view table creation statements or delete views. |
|
string |
Table object owner. |
|
string |
View object owner. |
|
string |
Table object creation time. |
|
string |
View object creation time. |
|
integer |
Number of table object rows. |
|
integer |
Number of view object rows. |
|
integer |
Table object size. |
|
integer |
View object size. |
In field paths, [] denotes each item in an array. For example, items[].name is the name field of each item in the items array.
Error response¶
codeinteger or string- Error code or status.
messagestring- Error message.
Error response example
{
"code": 400,
"message": "name 不能为空"
}
Follow-up operations¶
Save the identification of the target item, and then query table information.