My80
My80

Reputation: 169

Creating structure of all tables from one database in other snowflake database

I have two db on one snowflake account. Database db1 with schema sch_a and db2 with sch_b. I would like to create all tables from db1, schema sch_a in db2, sch_b. How can I move all tables from one db to other db? I need just structure of the tables without data, so empty tables. Thank you in advance.

Upvotes: 0

Views: 751

Answers (1)

Himanshu Kandpal
Himanshu Kandpal

Reputation: 1608

you can use the GET_DDL or CREATE … CLONE

-- THis will give you the DDL of all the objects in the schema
select get_ddl ('schema', 'source', true);

-- THis will copy the DB with the data
create database mytestdb_clone clone mytestdb;

https://docs.snowflake.com/en/sql-reference/sql/create-clone.html

Upvotes: 1

Related Questions