SHOW CREATE TABLE returns the complete DDL statement used to create a table. Run the returned statement directly to replicate the table schema in another environment.
Unlike DESCRIBE, which returns a column-by-column summary, SHOW CREATE TABLE returns a full, executable CREATE TABLE statement.
Prerequisites
Before you begin, ensure that you have:
LindormTable 2.6.2 or later
Lindorm SQL later than version 2.6.3.2
To check your Lindorm SQL version, see View Lindorm SQL versions.
Syntax
SHOW CREATE TABLE table_identifierLimitations
Table attributes are not included. Options set in the
WITHclause when the table was created—such asCOMPRESSION,TTL, andDYNAMIC_COLUMNS—do not appear in the output. To view these attributes, log on to the cluster management system. See Table attributes (table_options).Dynamic columns are not included. Columns added to the table after creation via
UPSERT INTOdo not appear in the output.Applicable to LindormTable only.
SHOW CREATE TABLEis not supported on other Lindorm engines.
Examples
Basic usage
Create a table named sensor:
CREATE TABLE sensor (
p1 INT,
c1 INT,
c2 VARCHAR,
PRIMARY KEY (p1)
) WITH (COMPRESSION='ZSTD', TTL='2592000', DYNAMIC_COLUMNS='TRUE');Run SHOW CREATE TABLE to get the DDL statement:
SHOW CREATE TABLE sensor;Output:
TABLE | CREATE TABLE
-------+--------------------------------------------------
sensor | CREATE TABLE sensor(p1 int NOT NULL, c1 int,
| c2 varchar, PRIMARY KEY (p1))The output contains only the columns declared in the original CREATE TABLE statement. Table attributes (COMPRESSION, TTL, DYNAMIC_COLUMNS) and any dynamic columns are not included.
Output when dynamic columns exist
After adding a dynamic column c3 to the sensor table:
UPSERT INTO sensor (p1, c2, c3) VALUES (1, '1', '41');Running SHOW CREATE TABLE sensor still returns the same output as the basic usage example. The dynamic column c3 and the WITH clause options (COMPRESSION, TTL, DYNAMIC_COLUMNS) are not included.
What's next
CREATE TABLE — Full syntax for creating tables, including all
WITHclause optionsView Lindorm SQL versions — Check which Lindorm SQL version your instance is running