---json { "name":"Duplicate a snowflake schema ", "canonical":"howto:database:table_create_with_dependencies", "title":"How to copy the data definition of all tables from a star/snowflake schema", "description":"This howto will show you how to copy the data definition of all SQL tables from a star/snowflake schema." } --- ====== Tabli - How to copy the data definition of all tables from a star/snowflake schema ====== ===== About ===== This [[..:howto|Howto]] will show you how to copy the [[docs:resource:structure|data definition]] of all [[docs:resource:table|SQL tables]] from a star/snowflake schema by using the [[docs:tabli:data:create|Tabli data create command]]. This command does not copy the data. It just [[docs:op:create|create]] the structure (ie it performs a SQL ''CREATE'' statement). If you want to copy the data, use the [[docs:tabli:data:transfer|tabli data transfer command]] instead. ===== Steps ===== ==== Prerequisites ==== You should have ''Tabulify'' installed on your computer. [[howto:getting_started:1_install]] ==== Select the fact table ==== The trick to copy a star/snowflake schema is: * to give the fact table (ie the table at the center of the star/snowflake schema) to the [[docs:tabli:data:create|Tabli table create command]] * and to ask to create it with its dependencies. ==== Create the fact table with its dependencies ==== Delete the target destination tabli data drop --not-strict *@sqlite The below command will [[docs:op:create|create]]: * the table ''store_sales'' from the [[docs:system:tpcds|tpcds]] system. This is the fact table of the tpcds store schema. * with all its dependencies (all the foreign tables) * into the [[docs:connection:default|Sqlite Howto connection]] with the prefix ''tpc_'' using [[docs:resource:target_uri|wildcard back referencing in the target]] * with the [[docs:tabli:data:create|tabli data create]] command. tabli data create --with-dependencies store_sales@tpcds tpc_$0@sqlite The list of data resources created uri --------------------------------- tpc_customer@sqlite tpc_customer_address@sqlite tpc_customer_demographics@sqlite tpc_date_dim@sqlite tpc_household_demographics@sqlite tpc_income_band@sqlite tpc_item@sqlite tpc_promotion@sqlite tpc_store@sqlite tpc_store_sales@sqlite tpc_time_dim@sqlite ==== List the created tables ==== With the [[docs:tabli:data:list|tabli data list]] command, we can list the tables created with the ''tpc'' prefix. tabli data list -a name -a count tpc*@sqlite count ----- 0 0 0 0 0 0 0 0 0 0 0 ==== Next ==== You can fill them with generated data. [[howto:generator:fill_schema|How to fill a schema with generated data]]