Create database¶
Create a database under the specified Catalog.
POST https://moi.matrixorigin.cn/newmoi/catalog/database/create
Preparation before calling¶
First query the catalog list to obtain the parent catalog ID. Prepare a personal access token with access to the target workspace, the target workspace ID, and the parent catalog ID.
The example below uses:
$AI_STUDIO_API_KEY: The actual personal access token, passed through theX-API-KeyHeader.$WORKSPACE_ID: Target workspace ID, passed throughX-Workspace-IDHeader.$CATALOG_ID: The parent catalog ID under which the database is to be created.
Request example¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/catalog/database/create" \
-H "X-API-Key: $AI_STUDIO_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.