View table or view creation statement

View the create statement for the table or view. The response contains the object definition and does not contain the data from the table.

HTTP
POST $CLOUDSIGMA_API_BASE/meta/table/ddl

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 the database name.

  3. Query the table and view list in the database, select the table or view name.

Request body

Replace $CLOUDSIGMA_API_KEY, $WORKSPACE_ID, $DATABASE, $TABLE in the example with actual values.

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

Parameter

Type

Required

Description

db_name

string

Yes

The name of the database where the table or view resides.

table_name

string

Yes

The name of the table or view to read DDL from.

Successful response

JSON
{
  "code": 200,
  "data": {
    "create_sql": "CREATE TABLE orders (id INT PRIMARY KEY)"
  }
}

Field

Type

Description

code

integer

200 on success.

data

object

Create statement for a table or view.

data.create_sql

string

CREATE TABLE statement for a table, or CREATE VIEW statement for a view.

Error response

JSON
{
  "code": 404,
  "message": "对象不存在"
}

Field

Type

Description

code

integer or string

Error code or status code.

message

string

error message.

Last updated on