SHOW CREATE
The SHOW CREATE statement returns the DDL that creates an object: a table, a view, a
materialized view, a task, or a trigger.
A view, a materialized view and a task each kept the statement that defined them, so
showing one returns that statement verbatim rather than a re-printed normalisation of it.
A table kept none — its shape is the catalog's, not a statement anybody stored — so its
DDL is reconstructed from its columns, their nullability, the relationships declared
on it and its clustering. A trigger kept only its own fields (target, event, schedule);
owner, suspend state and the minimum firing interval have no CREATE TRIGGER clause of
their own — they are exclusively ALTER TRIGGER forms — so a trigger whose
owner, suspend state or interval differs from what a fresh registration would set renders
as the CREATE TRIGGER plus trailing ALTER TRIGGER statements for each, the way a
clustered table's SHOW CREATE TABLE renders a trailing ALTER TABLE ... CLUSTER BY.
Syntax
SHOW CREATE TABLE <table_name>;
SHOW CREATE VIEW <view_name>;
SHOW CREATE MATERIALIZED VIEW <view_name>;
SHOW CREATE TASK <task_name>;
SHOW CREATE TRIGGER <trigger_name> ON <table_name>;Parameters
<table_name>/<view_name>/<task_name>— fully qualified as<workspace>.<collection>.<name>.<trigger_name>— the trigger to show. A trigger name is only unique per holder, soON <table_name>names it — the same convention ALTER TRIGGER and DROP TRIGGER use.
Result Columns
The result has one row and two columns: a label (the object name for
TABLE/VIEW/MATERIALIZED VIEW/TASK, or <trigger_name> ON <table_name> for a
trigger, used as the column name itself, holding that same label again) and
create_statement, holding the DDL.
Examples
A View's Definition
SHOW CREATE VIEW workspace.collection.active_customers;A Table's Shape, Reconstructed
SHOW CREATE TABLE my_workspace.raw.events;A Task's Statement
SHOW CREATE TASK my_workspace.ops.ingest_events;A Trigger's Definition
SHOW CREATE TRIGGER ingest_on_events ON my_workspace.raw.events;Notes
- A clustered table returns two statements — a
CREATE TABLEfollowed by anALTER TABLE ... CLUSTER BY— becauseCREATE TABLEhas noCLUSTER BYclause to carry it. Constraints need no such split:CREATE TABLEtakes them. A columnDEFAULTis never rendered, because none is stored —ADD COLUMN ... DEFAULTis a backfill value, not state a laterINSERTconsults. - A table created by
CTASrenders as an explicit-columnCREATE TABLE, because the defining query was never kept — unlike a materialized view's, which is. - A task's
ON <table>clause is not rendered: it creates a trigger rather than belonging to the task, andSHOW CREATE TRIGGER/ SHOW TRIGGERS FOR show those. - Requires read access to the object:
WRITEfor a view or materialized view (its body names the relations it reads, so showing it is treated the same as running it would be), andAUTOMATEfor a task or trigger (the same tier that creates or drops one — a trigger's definition names the identity its unattended runs carry). - Naming an object of the wrong kind is not found, rather than answered from whatever
holds the name —
SHOW CREATE TABLEon a materialized view's backing store is refused by name, not silently described as a plain table. FUNCTION,PROCEDUREandEVENTparse but are refused: Opteryx has no such object to define.- Raises an error if the named object does not exist.