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

code

integer

200 on success.

data.db_name

string

The name of the database being queried.

data.tables.tables

array of object or null

Table list. The service may return null when there are no tables; treat this as an empty list.

data.views.tables

array of object or null

View list. The service may return null when there are no views; treat this as an empty list.

data.tables.total

integer

Number of objects in the table list.

data.views.total

integer

Number of objects in the view list.

data.tables.tables[].name

string

Table name; used to query table information, fields or table creation statements.

data.views.tables[].name

string

View name; used to view table creation statements or delete views.

data.tables.tables[].owner

string

Table object owner.

data.views.tables[].owner

string

View object owner.

data.tables.tables[].created

string

Table object creation time.

data.views.tables[].created

string

View object creation time.

data.tables.tables[].rows

integer

Number of table object rows.

data.views.tables[].rows

integer

Number of view object rows.

data.tables.tables[].size

integer

Table object size.

data.views.tables[].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.

Last updated on