Create database¶
Create a database under the specified Catalog.
POST $CLOUDSIGMA_API_BASE/catalog/database/create
Before you call this API¶
Configure the regional API endpoint and authentication, and select the target workspace.
First query the catalog list to obtain the parent catalog ID.
Set the operation-specific values used in the request:
$CATALOG_ID: The parent catalog ID under which the database is to be created.
Request¶
curl -X POST "$CLOUDSIGMA_API_BASE/catalog/database/create" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"catalog_id": '"$CATALOG_ID"',
"name": "<DATABASE_NAME>",
"description": "<DATABASE_DESCRIPTION>"
}'
Request body
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
integer |
Yes |
The parent Catalog ID. |
|
string |
Yes |
Database name, must be a valid identifier. |
|
string |
No |
Database description. |
Successful response¶
Returns 200 on success. Save data.id for subsequent operations.
{
"code": "OK",
"msg": "OK",
"data": {
"id": 2
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
integer or null |
Create a new database ID; if not provided by the server, it is |
Error response¶
{
"code": "ErrAlreadyExists",
"msg": "数据库名称已存在",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
The request field is missing, or the name is not a valid identifier. |
Check |
|
|
The current identity does not have the permission to create a database in the parent Catalog. |
Requesting permission to |
|
|
There is already a database with the same name in the parent Catalog. |
Change the name. |
|
|
The parent object is a read-only system object. |
Select Writable Catalog. |
|
|
The server failed to create the database. |
Try again later. |
Follow-up operations¶
Use data.id Query database details.