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 the X-API-Key Header.

  • $WORKSPACE_ID: Target workspace ID, passed through X-Workspace-ID Header.

  • $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

database_id

integer

Yes

Database ID.

name

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

code

string

OK on success.

msg

string

OK on success.

data

object

Existence check result.

data.data

boolean

true indicates that the table exists; false indicates that the table does not exist.

Error response

{
  "code": "ErrParamInvalid",
  "msg": "请求参数无效",
  "data": null
}

Common HTTP errors

HTTP status code

error code

Common causes

Recommended actions

400

ErrParamInvalid

The request body format, database ID, or table name is invalid.

Check database_id and name.

403

ErrForbidden

The current identity does not have read permissions for the corresponding database.

Check workspace and database authorization.

500

ErrServer

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.

Last updated on