Skip to main content
Returns the CREATE TABLE statement that was used to create a given table.
NOTE In versions earlier than v3.0, the SHOW CREATE TABLE statement requires you to have the SELECT_PRIV privilege on the table. Since v3.0, the SHOW CREATE TABLE statement requires you to have the SELECT privilege on the table.
Since v3.0, you can use the SHOW CREATE TABLE statement to view the CREATE TABLE statements of the tables that are managed by an external catalog and are stored in Apache Hive™, Apache Iceberg, Apache Hudi, or Delta Lake. Since v2.5.7, the database can automatically set the number of buckets (BUCKETS) when you create a table or add a partition. You no longer need to manually set the number of buckets. For detailed information, see set the number of buckets.
  • If you specified the number of buckets when creating a table, the output of SHOW CREATE TABLE will display the number of buckets.
  • If you did not specify the number of buckets when creating a table, the output of SHOW CREATE TABLE will not display the number of buckets. You can run SHOW PARTITIONS to view the number of buckets for each partition.
In versions earlier than v2.5.7, you are required to set the number of buckets when creating a table. Therefore, SHOW CREATE TABLE displays the number of buckets by default.

Syntax

Parameters

Output

The following table describes the parameters returned by this statement.

Examples

Bucket number is not specified

Create a table named example_table with no bucket number specified in DISTRIBUTED BY.
Run SHOW CREATE TABLE to display the CREATE TABLE statement of example_table. No bucket number is displayed in DISTRIBUTED BY. Note that if you did not specify PROPERTIES when you create the table, the default properties are displayed in the output of SHOW CREATE TABLE.

Bucket number is specified

Create a table named example_table1 with bucket number set to 10 in DISTRIBUTED BY.
Run SHOW CREATE TABLE to display the CREATE TABLE statement of example_table. The bucket number (BUCKETS 10) is displayed in DISTRIBUTED BY. Note that if you did not specify PROPERTIES when you create the table, the default properties are displayed in the output of SHOW CREATE TABLE.

References