---
title: SHOW CREATE TABLE
description: Return the CREATE statement that defines an existing table with SHOW CREATE TABLE in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-aux-show-create-table
---

# SHOW CREATE TABLE

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

> [!NOTE]
>
> To use this command on materialized views or streaming tables, you must use Databricks Runtime version 14.1 or above.

Returns the statement that was used to create a given table or view. The returned statement can be any of the following types:

* [CREATE TABLE](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-create-table.md)
* [CREATE VIEW](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-create-view.md)

- [CREATE MATERIALIZED VIEW](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-create-materialized-view.md)
- [CREATE STREAMING TABLE](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-create-streaming-table.md)

`SHOW CREATE TABLE` on a temporary view or non-existent table throws an exception.

## Syntax

```
SHOW CREATE TABLE { table_name | view_name }
```

## Parameters

* **[table\_name](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-names.md#table-name)**

  Identifies the relation. The name must not include a [temporal specification or options specification](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-names.md#table-name).

## Examples

```sql
> CREATE TABLE test (c INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
    STORED AS TEXTFILE
    TBLPROPERTIES ('prop1' = 'value1', 'prop2' = 'value2');

> SHOW CREATE TABLE test;
                                       createtab_stmt
 ----------------------------------------------------
 CREATE TABLE `default`.`test` (`c` INT)
 USING text
 TBLPROPERTIES (
   'transient_lastDdlTime' = '1586269021',
   'prop1' = 'value1',
   'prop2' = 'value2')
```

The following example shows `SHOW CREATE TABLE` for a metric view. The output captures the original definition and any subsequent `ALTER VIEW` changes, and the view name is returned as a fully qualified three-part name.

```sql
> CREATE OR REPLACE VIEW sample_sales_metrics_v2
    COMMENT 'Sales metrics for product and regional analysis'
    TBLPROPERTIES ('created_by' = 'Evan')
    WITH METRICS
    LANGUAGE YAML
    AS $$
  version: 1.1
  source: sample_sales
  comment: "Sales metrics for product and regional analysis"

  dimensions:
    - name: product_category
      expr: product_category
      comment: "Category of the product sold"
    - name: region
      expr: region
  measures:
    - name: total_sales
      expr: SUM(sales_amount)
      comment: "Sum of all sales amounts"
    - name: total_quantity
      expr: SUM(quantity)
      comment: "Total number of items sold"
  $$;

> ALTER VIEW sample_sales_metrics_v2
    SET TBLPROPERTIES ('purpose' = 'For testing');

> SHOW CREATE TABLE sample_sales_metrics_v2;
                              createtab_stmt
 ------------------------------------------------------------
 CREATE VIEW main.default.sample_sales_metrics_v2 (
   product_category COMMENT 'Category of the product sold',
   region,
   total_sales COMMENT 'Sum of all sales amounts',
   total_quantity COMMENT 'Total number of items sold')
 COMMENT 'Sales metrics for product and regional analysis'
 TBLPROPERTIES (
   'created_by' = 'Evan',
   'purpose' = 'For testing')
 WITH METRICS
 LANGUAGE YAML
 AS
 $$
 version: 1.1

 source: sample_sales

 comment: Sales metrics for product and regional analysis

 dimensions:
   - name: product_category
     expr: product_category
     comment: Category of the product sold
   - name: region
     expr: region

 measures:
   - name: total_sales
     expr: SUM(sales_amount)
     comment: Sum of all sales amounts
   - name: total_quantity
     expr: SUM(quantity)
     comment: Total number of items sold
 $$
```

## Related articles

* [CREATE TABLE](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-create-table.md)

- [CREATE STREAMING TABLE](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-create-streaming-table.md)

* [CREATE VIEW](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-create-view.md)
* [Create a metric view](https://docs.databricks.com/aws/en/uc-semantics/metric-views/create.md)

- [CREATE MATERIALIZED VIEW](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-create-materialized-view.md)

* [INFORMATION\_SCHEMA.COLUMNS](https://docs.databricks.com/aws/en/sql/language-manual/information-schema/columns.md)
* [INFORMATION\_SCHEMA.TABLES](https://docs.databricks.com/aws/en/sql/language-manual/information-schema/tables.md)
* [INFORMATION\_SCHEMA.VIEWS](https://docs.databricks.com/aws/en/sql/language-manual/information-schema/views.md)
