Check if the table exists¶
Checks whether the given table name exists in the specified database.
POST https://moi.matrixorigin.cn/newmoi/catalog/table/exist
Preparation before calling¶
First query the database list to obtain the target database ID. Prepare the personal access token, target workspace ID, and database ID that have access to the target workspace.
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.$DATABASE_ID: Database ID to check.
Request example¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/catalog/table/exist" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"database_id": '"$DATABASE_ID"',
"name": "<TABLE_NAME>"
}'
Request body¶
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
integer |
Yes |
Database ID. |
|
string |
Yes |
The name of the table to check. |
Successful response¶
Returns 200 and the existence check result on success. This result only indicates that the check has completed and the table will not be created or modified.
{
"code": "OK",
"msg": "OK",
"data": {
"data": true
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
object |
Existence check result. |
|
boolean |
|
Error response¶
{
"code": "ErrParamInvalid",
"msg": "请求参数无效",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
The request body format, database ID, or table name is invalid. |
Check |
|
|
The current identity does not have read permissions for the corresponding database. |
Check workspace and database authorization. |
|
|
The service cannot check whether the table exists. |
Record the request time and error message and try again; if it continues to fail, contact support. |
Follow-up operations¶
When the table exists, Query table information; when it does not exist, Create table.