Create table¶
Creates a table in the specified database.
POST $CLOUDSIGMA_API_BASE/catalog/table/create
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. First query the database list to obtain the target database ID. Prepare the personal access token, target workspace ID, and database ID that can access the target workspace. Table creation is not possible for system, retention, or subscription databases.
Request body¶
curl -X POST "$CLOUDSIGMA_API_BASE/catalog/table/create" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"database_id": '"$DATABASE_ID"',
"name": "<TABLE_NAME>",
"columns": [
{
"name": "id",
"type": "INT",
"is_pk": true
},
{
"name": "amount",
"type": "DECIMAL"
}
]
}'
Field |
Type |
Required |
Description |
|---|---|---|---|
|
integer |
Yes |
Target database ID. |
|
string |
Yes |
Table name, must be a valid identifier. |
|
array of object |
Yes |
Column definition. |
|
string |
No |
Table comments. |
|
string |
No |
Currently received but not used, data import will not be triggered. Please use the data import task separately after creating the table. |
|
array of object |
No |
Currently received but not used, does not change the column loading method. |
|
string |
Yes |
Column name. |
|
string |
Yes |
Full SQL data type, such as BIGINT or DECIMAL(10,2). |
|
boolean |
No |
Whether it is a primary key column. |
|
string |
No |
Column comments. |
|
integer (integer array) |
No |
Currently received but not used. The precision needs to be written in the complete type, such as DECIMAL(10,2). |
|
string |
No |
SQL literal expression of default value. String defaults must contain the single quotes required by SQL. |
|
string |
No |
Column name to configure. |
|
string |
No |
Data source: |
Successful response¶
{
"code": "OK",
"msg": "OK",
"data": {
"id": 1001
}
}
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
integer |
ID of the new table. |
Error response¶
{
"code": "ErrReadonlySystemDatabase",
"msg": "数据库不可写"
}
Field |
Type |
Description |
|---|---|---|
|
string |
error code. |
|
string |
error message. |