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.
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.
Prepare personal access token and target workspace ID that can access the target workspace.
View database, select the database name.
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.
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 |
|---|---|---|---|
|
string |
Yes |
The name of the database where the table or view resides. |
|
string |
Yes |
The name of the table or view to read DDL from. |
Successful response¶
{
"code": 200,
"data": {
"create_sql": "CREATE TABLE orders (id INT PRIMARY KEY)"
}
}
Field |
Type |
Description |
|---|---|---|
|
integer |
200 on success. |
|
object |
Create statement for a table or view. |
|
string |
CREATE TABLE statement for a table, or CREATE VIEW statement for a view. |
Error response¶
{
"code": 404,
"message": "对象不存在"
}
Field |
Type |
Description |
|---|---|---|
|
integer or string |
Error code or status code. |
|
string |
error message. |