View tables and views in a database

List the tables and views in a database. Select subsequent actions based on the object type.

HTTP
POST $CLOUDSIGMA_API_BASE/meta/db/table

Before you call

Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region.

  1. Prepare personal access token and target workspace ID that can access the target workspace.

  2. View database, select and record the database name (db_name).

Request body

Replace $CLOUDSIGMA_API_KEY, $WORKSPACE_ID, $DATABASE 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\"
  }"

Parameter

Type

Required

Description

name

string

Yes

The name of the database to view.

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
    }
  }
}

Field

Type

Description

code

integer

200 on success.

data

object

Tables and views in the database.

data.db_name

string

The name of the database being viewed.

data.tables

object

List of tables and their total number.

data.views

object

List of views and their total number.

data.tables.tables

array of objects or null

Table list. The service may return null when there is no table. Treat it as an empty list.

data.tables.total

integer

The number of objects in the table list.

data.tables.tables[].name

string

Table name. Used to view table information, fields or table creation statements.

data.tables.tables[].owner

string

The current list is not populated with owners, returning an empty string.

data.tables.tables[].created

string

The current list is not populated with creation time and returns an empty string.

data.tables.tables[].rows

integer

The current list uses 0 placeholder, not the actual number of rows. When the number of rows is required, call the view table information interface.

data.tables.tables[].size

integer

The current list is not padded to size, returning 0.

data.views.tables

array of objects or null

View list. The service may return null when there is no view. Treat it as an empty list.

data.views.total

integer

The number of objects in the view list.

data.views.tables[].name

string

View name. Used to view the create statement of the view or delete the view.

data.views.tables[].owner

string

The current list is not populated with owners, returning an empty string.

data.views.tables[].created

string

The current list is not populated with creation time and returns an empty string.

data.views.tables[].rows

integer

The current list uses 0 placeholder, not the actual number of rows. When the number of rows is required, call the view table information interface.

data.views.tables[].size

integer

The current list is not padded to size, returning 0.

Error response

JSON
{
  "code": 400,
  "message": "name 不能为空"
}

Field

Type

Description

code

integer or string

Error code or status code.

message

string

error message.

Last updated on