Generate and save the full DDL of a Snowflake schema so it can be recreated elsewhere.
Exporting a schema means extracting every CREATE statement—tables, views, sequences, functions, procedures, and grants—so you can rebuild the schema in another account, database, or environment.
The GET_DDL system function returns the exact DDL for a specified object. Passing a schema name plus the ‘schema’ object type returns DDL for every object inside the schema.
GET_DDL(object_type, object_name [, show_semi_qualified]) outputs a single VARCHAR value containing the CREATE statements. Use ‘schema’ as object_type and a fully-qualified schema name (e.g., ‘ECOMMERCE.PUBLIC’).
SELECT GET_DDL('schema', 'ECOMMERCE.PUBLIC');
CREATE OR REPLACE STAGE admin.ddl_stage;
COPY INTO @admin.ddl_stage/ddl.sql
FROM (SELECT GET_DDL('schema', 'ECOMMERCE.PUBLIC'))
FILE_FORMAT = (TYPE = CSV COMPRESSION = GZIP FIELD_DELIMITER = NONE);
This writes a gzip-compressed file called ddl.sql.gz to the stage.
GET @admin.ddl_stage/ddl.sql.gz file://./
Yes. Replace ‘schema’ with ‘table’ in GET_DDL and supply a fully-qualified table name.
Unzip the file, then run the DDL in your target Snowflake environment using SnowSQL or the UI worksheet.
GET_DDL builds fully-syntactic CREATE statements—including clustering keys, constraints, masking policies, and grants—saving manual work.
Yes, when you export a schema Snowflake appends GRANT statements for each object so privileges can be replicated.
Use a Snowflake task or an external scheduler (e.g., Airflow, GitHub Actions) to run COPY INTO nightly and push the file to S3 or Git.
GET_DDL returns up to 16 MB per row. Very large schemas rarely exceed this, but if they do, split the export per object type.