GET_DDL

functionsupportedDatabases & schemas

docs.snowflake.com ↗

Metadata functions

Returns a DDL statement that can be used to recreate the specified object. For databases and schemas, GET_DDL is recursive (that is, it returns the DDL statements for recreating all supported objects within the specified database/schema). GET_DDL currently supports the following object types: - Cortex Agents (see CREATE AGENT) - Cortex Search services (see CREATE CORTEX SEARCH SERVICE) - MCP servers (see CREATE MCP SERVER) - Alerts (see CREATE ALERT) - Databases (see CREATE DATABASE), including catalog-linked databases. - Data metric functions (see CREATE DATA METRIC FUNCTION) - Contacts (see CREATE CONTACT) - dbt project objects (see CREATE DBT PROJECT) - Dynamic tables (see CREATE DYNAMIC TABLE) - Event tables (see CREATE EVENT TABLE) - External tables (see CREATE EXTERNAL TABLE) - Failover groups (see CREATE FAILOVER GROUP) - File formats (see CREATE FILE FORMAT) - Hybrid tables (see CREATE HYBRID TABLE) - Apache Iceberg™ tables (see CREATE ICEBERG TABLE) - Notebooks (see CREATE NOTEBOOK) - Online feature tables (see CREATE ONLINE FEATURE TABLE) - Openflow deployments, runtimes, and connectors (see CREATE OPENFLOW DEPLOYMENT, CREATE OPENFLOW RUNTIME, CREATE OPENFLOW CONNECTOR) - Pipes (see CREATE PIPE) - Policies (see CREATE AGGREGATION POLICY , CREATE AUTHENTICATION POLICY , CREATE DATA MOVEMENT POLICY , CREATE INGRESS POLICY , CREATE JOIN POLICY , CREATE MASKING POLICY , CREATE PASSWORD POLICY , CREATE PRIVACY POLICY , CREATE PROJECTION POLICY , CREATE ROW ACCESS POLICY , CREATE SESSION POLICY, CREATE STORAGE LIFECYCLE POLICY) - Data movement rules (see CREATE DATA MOVEMENT RULE) - Replication groups (see CREATE REPLICATION GROUP) - Schemas (see CREATE SCHEMA) - Semantic views (see CREATE SEMANTIC VIEW) - Sequences (see CREATE SEQUENCE) - Storage integrations (see CREATE STORAGE INTEGRATION) - Stored procedures (see CREATE PROCEDURE) - Streams (see CREATE STREAM) - Tables (see CREATE TABLE) - Tags (see CREATE TAG) - Tasks (see CREATE TASK) - UDFs, including external functions (see CREATE FUNCTION) - User-defined types (see CREATE TYPE) - Views (see CREATE VIEW) - Warehouses (see CREATE WAREHOUSE)

Syntax

supportedpartialnot supportednot scored

GET_DDL( '<object_type>' , '[<namespace>.]<object_name>' [ , <use_fully_qualified_names_for_recreated_objects> ] )

Parameters

NameRequiredDescription
'object_type'requiredSpecifies the type of object for which the DDL is returned. Valid values (corresponding to the supported object types) are: CORTEX_AGENT CORTEX_SEARCH_SERVICE CONTACT DATABASE DATA MOVEMENT RULE DYNAMIC_TABLE EVENT_TABLE FAILOVER_GROUP FILE_FORMAT FUNCTION (for UDFs, including data metric functions and external functions) ICEBERG_TABLE INTEGRATION (storage) MCP_SERVER PIPE POLICY (aggregation, authentication, data movement, ingress, join, masking, password, projection, row access, session, and storage lifecycle policies) PROCEDURE (for stored procedures) REPLICATION_GROUP SCHEMA SEMANTIC VIEW SEQUENCE STREAM TABLE (for tables, external tables, and hybrid tables) TAG (object tagging) TASK TYPE VIEW (for views and materialized views) WAREHOUSE
'namespace.object_name'requiredSpecifies the fully-qualified name of the object for which the DDL is returned. Namespace is the database and/or schema in which the object resides: Not used for databases. For schemas, takes the form of database. For schema objects (tables, views, streams, tasks, sequences, file formats, pipes, policies, and UDFs), takes the form of database.schema or schema. Namespace is optional if a database and schema are currently in use within the user session; otherwise, it is required.
use_fully_qualified_names_for_recreated_objectsoptionalIf TRUE, the generated DDL statements use fully qualified names for the objects to be recreated. Default: FALSE. Note This does not affect the names of other objects referenced in the DDL statement (e.g. the name of a table referenced in a view definition).

Returns

Returns a string (a VARCHAR value) containing the text of the DDL statement that created the object. For UDFs and stored procedures, the output might be slightly different from the original DDL. For example, if the UDF or stored procedure contains JavaScript code, the delimiter characters around the JavaScript code might be different. In addition, note that the DDL statement returned by the function might include default values for properties. For example, even if the original CREATE PROCEDURE statement did not specify EXECUTE AS OWNER, the DDL statement returned by the function includes EXECUTE AS OWNER, which is the default.

Usage notes

Access control requirements

- For semantic views, you must use a role that has been granted the REFERENCES or OWNERSHIP privilege on the semantic view.

Collation details

- Collation information is included in the input.