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.

HTTP
POST $CLOUDSIGMA_API_BASE/meta/db/table

Before you call this API

Configure the regional API endpoint and authentication, and select the target workspace.

You can first query database to confirm the name.

Request

Replace caller-specific values in the example with actual values.

Shell
curl -X POST "$CLOUDSIGMA_API_BASE/meta/db/table" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d "{\"name\":\"$DATABASE\"}"

Request body

ParameterTypeRequiredDescription
namestringRequiredThe name of the database to be queried.

Successful response

JSON
{
  "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

JSON
{
  "code": 400,
  "message": "name 不能为空"
}
FieldTypeDescription
codeinteger or stringError code or status.
messagestringError message.

Follow-up operations

Save the identification of the target item, and then query table information.

Last updated on