# View table or view creation statement

View the create statement for the table or view. The response contains the object definition and does not contain the data from the table.

```text
POST $CLOUDSIGMA_API_BASE/meta/table/ddl
```

## Before you call this API

Configure the [regional API endpoint and authentication](https://omnifabric.cloudsigma.com/docs/developer/endpoints-and-authentication.html.md), and select the target workspace.

You can first [query the table in the database](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-metadata/list-database-tables.html.md) to confirm the table or view name.

## Request body

Replace caller-specific values in the example with actual values.

::::{div} mo-api-split
:::{div} mo-api-split-main
<dl class="mo-api-fields">
<div class="mo-api-field"><dt><code>db_name</code><span class="mo-api-field__type">string</span><span class="mo-api-field__required">Required</span></dt><dd>The name of the database where the table or view resides.</dd></div>
<div class="mo-api-field"><dt><code>table_name</code><span class="mo-api-field__type">string</span><span class="mo-api-field__required">Required</span></dt><dd>The name of the table or view to read DDL from.</dd></div>
</dl>
:::
:::{div} mo-api-split-aside
<p class="mo-api-example-label">Request example</p>
```bash
curl -X POST "$CLOUDSIGMA_API_BASE/meta/table/ddl" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d "{\"db_name\":\"$DATABASE\",\"table_name\":\"$TABLE\"}"
```
:::
::::
## Successful response

```json
{"code":200,"data":{"create_sql":"CREATE TABLE orders (id INT PRIMARY KEY)"}}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | integer | `200` on success. |
| `data.create_sql` | string | The `CREATE TABLE` statement for a table, or the `CREATE VIEW` statement for a view. |

## Error response

::::{div} mo-api-split
:::{div} mo-api-split-main
<dl class="mo-api-fields">
<div class="mo-api-field"><dt><code>code</code><span class="mo-api-field__type">integer or string</span></dt><dd>Error code or status.</dd></div>
<div class="mo-api-field"><dt><code>message</code><span class="mo-api-field__type">string</span></dt><dd>Error message.</dd></div>
</dl>
:::
:::{div} mo-api-split-aside
<p class="mo-api-example-label">Error response example</p>
```json
{
  "code": 404,
  "message": "对象不存在"
}
```
:::
::::
## Follow-up operations

[View table column list](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-metadata/list-table-columns.html.md) when returning to the list.
