Clear the table¶
Delete all data in the table but retain the table definition. This operation is irreversible, please confirm the target table.
POST https://moi.matrixorigin.cn/newmoi/catalog/table/truncate
Preparation before calling¶
First query the object in the database to obtain the target table ID. Prepare the personal access token, target workspace ID, and table 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.$TABLE_ID: Table ID to be cleared.
This operation is irreversible, please confirm the target table.
Request example¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/catalog/table/truncate" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"id": '"$TABLE_ID"'
}'
Request body¶
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
integer |
Yes |
Table ID. |
Successful response¶
Returns 200 on success, data is null. The table definition will be retained and the data in the table will be deleted.
{
"code": "OK",
"msg": "OK",
"data": null
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
null |
Fixed to |
Error response¶
{
"code": "ErrReadonlySystemDatabase",
"msg": "数据库不可写",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
|
Pass in a valid table ID. |
|
|
The current identity does not have table write permission. |
Use credentials with write access, or contact your administrator for authorization. |
|
|
The table is located in a read-only system database. |
Select a table in a writable database. |
|
|
The service cannot clear table data. |
Record the request time and error message and try again; if it continues to fail, contact support. |
Follow-up operations¶
After completion, Query Catalog details confirms the result.