Create table¶
Creates a table in the specified database.
POST $CLOUDSIGMA_API_BASE/catalog/table/create
Before you call this API¶
Configure the regional API endpoint and authentication, and select the target workspace.
First query the database list to obtain the target database ID.
Set the operation-specific values used in the request:
$DATABASE_ID: The target database ID under which the table is to be created.
Table creation is not possible for system, retention, or subscription databases.
Request¶
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"
}
]
}'
Request body
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
integer |
Yes |
Target database ID. |
|
string |
Yes |
Table name, must be a valid identifier. |
|
array |
Yes |
A column definition. Each item must contain at least a column name and type. |
|
string |
No |
Table comment. |
|
string |
No |
URL of the data file to import; when empty only creates the table. |
|
array |
No |
Loading options for each column when importing data. |
Successful response¶
Returns 200 and the new table ID on success. Table creation is not possible for system, retention, or subscription databases.
{
"code": "OK",
"msg": "OK",
"data": {
"id": 1001
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
integer |
ID of the new table. |
Error response¶
{
"code": "ErrReadonlySystemDatabase",
"msg": "数据库不可写",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
|
Try again after providing the complete table definition. |
|
|
The current identity does not have permission to create tables in the target database. |
Use credentials with write access, or contact your administrator for authorization. |
|
|
The target database is not writable. |
Select a writable database. |
|
|
The service cannot create tables or import data. |
Record the request time and error message and try again; if it continues to fail, contact support. |
Follow-up operations¶
Use data.id Query table information.