Get table column names¶
Query column names of a table in a specified database for field selection.
POST https://api.moi.matrixorigin.cn/v5/table/columns
Before you call this API¶
BASE_URL uses the product API prefix https://api.moi.matrixorigin.cn/v5. For a dedicated deployment, use its corresponding product API address.
Obtain database ID and table name, or a table ID in that database. Prepare a personal access token with workspace/table read access and a workspace ID. BASE_URL includes the same environment’s product prefix. MOI_KEY and WORKSPACE_ID are product credentials and workspace ID. Example IDs/data are placeholders.
Request body¶
curl --fail-with-body -sS -X POST "$BASE_URL/table/columns" \
-H "X-API-Key: $MOI_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{"database_id": 10, "table_name": "orders"}'
Omit table_name when reading by table ID.
curl --fail-with-body -sS -X POST "$BASE_URL/table/columns" \
-H "X-API-Key: $MOI_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{"database_id":10,"table_id":31}'
Fields |
Type |
Required |
Description |
|---|---|---|---|
|
integer |
Yes |
Positive integer database ID. |
|
string |
Conditional |
Nonempty names take precedence over table_id. |
|
integer |
Conditional |
Positive table ID when table_name is empty; must belong to database_id. |
Returns column names only, not types or CREATE statements. ID lookup validates database ownership.
Successful response¶
{
"code": "OK",
"msg": "OK",
"data": {
"db_name": "sales",
"table_name": "orders",
"col_names": [
"id",
"amount"
]
}
}
Field |
Type |
Description |
|---|---|---|
|
string |
OK on success. |
|
string |
OK on success. |
|
string |
Database name. |
|
string |
Actual queried table name. |
|
string[] (array of strings) |
Column names; may be null without columns. |
Error response¶
{
"code": "ErrParamInvalid",
"msg": "示例错误信息"
}
HTTP |
code |
Condition |
|---|---|---|
400 |
ErrParamInvalid |
Invalid database ID or table locator. |
404 |
ErrNotFound |
Table missing, ID outside the database, or physical table not found. |
Use actual returned code, msg, and diagnostic fields for identity, permission, and dependency failures. Error text may vary by language.