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 this API

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

You can first query the table in the database to confirm the table or view name.

Request

Replace caller-specific values 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\"}"

Request body

ParameterTypeRequiredDescription
db_namestringRequiredThe name of the database where the table or view resides.
table_namestringRequiredThe 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)"}}

The response fields are as follows.

Field

Type

Description

code

integer

200 on success.

data.create_sql

string

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

Error response

JSON
{
  "code": 404,
  "message": "对象不存在"
}
FieldTypeDescription
codeinteger or stringError code or status.
messagestringError message.

Follow-up operations

View table column list when returning to the list.

Last updated on