---
search:
  tags:
    - database-services
    - GET
seo:
  description: >-
    Fetch a database service's schema (tables,… Reference for the GET
    /api/v1/database-services/{id}/sql/api/schema endpoint in the TimescaleDB
    Enterprise API.
sidebar:
  label: Fetch the database schema
  badge: GET
title: Fetch the database schema
type: openapi-operation
---
Fetch a database service's schema (tables, views, functions, hypertables, ...).

`GET /api/v1/database-services/{id}/sql/api/schema`

**Responses**

- `200` — OK
- `default` — Error

Response example, 200:

```json
{
  "id": "string",
  "name": "string",
  "schemas": [
    {
      "comment": "string",
      "enums": [
        {
          "comment": "string",
          "name": "string",
          "values": [
            "string"
          ]
        }
      ],
      "functions": [
        {
          "arguments": "string",
          "comment": "string",
          "definition": "string",
          "name": "string",
          "type": "string"
        }
      ],
      "materialized_views": [
        {
          "columns": [
            {
              "comment": "string",
              "name": "string",
              "type": "string"
            }
          ],
          "comment": "string",
          "continuous_aggregate": {
            "compression_enabled": true,
            "materialized_only": true
          },
          "definition": "string",
          "indexes": [
            {
              "columns": "string",
              "definition": "string",
              "is_unique": true,
              "name": "string",
              "where_clause": "string"
            }
          ],
          "name": "string",
          "triggers": [
            {
              "manipulation": "string",
              "name": "string",
              "statement": "string",
              "timing": "string"
            }
          ]
        }
      ],
      "name": "string",
      "procedures": [
        {
          "arguments": "string",
          "comment": "string",
          "definition": "string",
          "name": "string",
          "type": "string"
        }
      ],
      "tables": [
        {
          "checks": [
            {
              "columns": [
                "string"
              ],
              "expression": "string",
              "name": "string"
            }
          ],
          "columns": [
            {
              "comment": "string",
              "default": "string",
              "identity_type": "string",
              "is_serial": true,
              "name": "string",
              "not_null": true,
              "type": "string"
            }
          ],
          "comment": "string",
          "constraints": [
            {
              "columns": [
                "string"
              ],
              "name": "string",
              "ref_columns": [
                "string"
              ],
              "ref_table": "string",
              "type": "string"
            }
          ],
          "exclusions": [
            {
              "definition": "string",
              "name": "string"
            }
          ],
          "foreign": {
            "options": [
              "string"
            ],
            "server": "string",
            "wrapper": "string"
          },
          "hypertable": {
            "compression_enabled": true,
            "num_chunks": 0
          },
          "indexes": [
            {
              "columns": "string",
              "definition": "string",
              "is_unique": true,
              "name": "string",
              "where_clause": "string"
            }
          ],
          "name": "string",
          "partitions": [
            {
              "bound": "string",
              "name": "string",
              "schema": "string"
            }
          ],
          "triggers": [
            {
              "manipulation": "string",
              "name": "string",
              "statement": "string",
              "timing": "string"
            }
          ]
        }
      ],
      "views": [
        {
          "columns": [
            {
              "comment": "string",
              "name": "string",
              "type": "string"
            }
          ],
          "comment": "string",
          "continuous_aggregate": {
            "compression_enabled": true,
            "materialized_only": true
          },
          "definition": "string",
          "indexes": [
            {
              "columns": "string",
              "definition": "string",
              "is_unique": true,
              "name": "string",
              "where_clause": "string"
            }
          ],
          "name": "string",
          "triggers": [
            {
              "manipulation": "string",
              "name": "string",
              "statement": "string",
              "timing": "string"
            }
          ]
        }
      ]
    }
  ]
}
```
