Create table

Creates a table in the specified database.

HTTP
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

Shell
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

database_id

integer

Yes

Target database ID.

name

string

Yes

Table name, must be a valid identifier.

columns

array of object

Yes

Column definition.

comment

string

No

Table comments.

data_file_url

string

No

Currently received but not used, data import will not be triggered. Please use the data import task separately after creating the table.

column_load_options

array of object

No

Currently received but not used, does not change the column loading method.

columns[].name

string

Yes

Column name.

columns[].type

string

Yes

Full SQL data type, such as BIGINT or DECIMAL(10,2).

columns[].is_pk

boolean

No

Whether it is a primary key column.

columns[].comment

string

No

Column comments.

columns[].precision

integer (integer array)

No

Currently received but not used. The precision needs to be written in the complete type, such as DECIMAL(10,2).

columns[].default

string

No

SQL literal expression of default value. String defaults must contain the single quotes required by SQL.

column_load_options[].column

string

No

Column name to configure.

column_load_options[].data_from

string

No

Data source: 0 is read from the file, 1 uses the default value, and 2 is set to null.

Successful response

JSON
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "id": 1001
  }
}

Field

Type

Description

code

string

OK on success.

msg

string

OK on success.

data.id

integer

ID of the new table.

Error response

JSON
{
  "code": "ErrReadonlySystemDatabase",
  "msg": "数据库不可写"
}

Field

Type

Description

code

string

error code.

msg

string

error message.

Last updated on