<span id="查询指定数据库的表概览"></span>

# Get a database table overview

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

List readable registered tables and column names in the specified database.

```text
POST https://api.moi.matrixorigin.cn/v5/table/database/tables
```

<span id="调用前准备"></span>

## 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 the target database ID. Prepare a personal access token with workspace access and read access to target tables, plus 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.

<span id="请求体"></span>

## Request body

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Request example

```bash
curl --fail-with-body -sS -X POST "$BASE_URL/table/database/tables" \
  -H "X-API-Key: $MOI_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{"database_id": 10}'
```

:::::
:::::{tab-item} Parameters

| Fields | Type | Required | Description |
| --- | --- | --- | --- |
| `database_id` | integer | Yes | Positive integer database ID. |

A registered table may still return when physical schema is missing, with col_names=[]. This differs from missing-table handling in workspace-wide overviews.

:::::
::::::
:::::::

<span id="成功响应"></span>

## Successful response

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "tables": [
      {
        "db_name": "sales",
        "table_name": "orders",
        "col_names": [
          "id",
          "amount"
        ]
      }
    ]
  }
}
```

:::::
:::::{tab-item} Fields

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | OK on success. |
| `msg` | string | OK on success. |
| `data.tables` | object[] (array of objects) or null | Table overviews in the database; may be null without results. |
| `data.tables[].db_name` | string | Database name. |
| `data.tables[].table_name` | string | Registered table name. |
| `data.tables[].col_names` | string[] (array of strings) | Column names. Empty array if physical schema is missing; a physical column collection may also be null. |

:::::
::::::
:::::::

<span id="错误响应"></span>

## Error response

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": "ErrParamInvalid",
  "msg": "示例错误信息"
}
```

:::::
:::::{tab-item} Fields

| HTTP | code | Condition |
| --- | --- | --- |
| 400 | ErrParamInvalid | Invalid database ID. |
| 404 | ErrNotFound | Database does not exist. |

Use actual returned code, msg, and diagnostic fields for identity, permission, and dependency failures. Error text may vary by language.

:::::
::::::
:::::::
