---json { "canonical": ":howto:database:table_create_from_script", "description": "This Howto will show you how to create a SQL table with a SQL file that contains a ''CREATE'' SQL statement", "low_quality_page": "false", "name": "Table Creation From Script", "page_id": "2y8to1aqf22td1go8fy0d", "title": "How to create a table with a CREATE Sql statement file" } --- ====== Tabulify - How to create a table with a CREATE Sql statement file ====== ===== About ===== This [[..:howto|Howto]] will show you how to create a [[docs:resource:table|SQL table]] with a SQL file that contains a ''CREATE'' SQL statement with the [[docs:tabli:data:create|Tabli table create command]]. ===== Steps ===== ==== Prerequisites ==== You should have ''Tabulify'' installed on your computer: [[howto:getting_started:1_install]] ==== The CREATE table statement ==== Delete the target destination tabli data drop --not-strict *@sqlite We will execute the below [[docs:resource:script|SQL Script]] that is located in the [[docs:connection:howto|howto connection]]. -- Create the foo table statement create table foo ( bar integer ) ==== The data create command ==== With the [[docs:tabli:data:create|tabli data create]] command, if you use a [[docs:resource:script_selector|script selector]] as first argument, the selected [[docs:resource:script|script]] are executed. To execute the previous SQL script, the below the command should be executed: tabli data create (create_foo.sql@howto)@sqlite where: * ''data create'' is the [[docs:tabli:data:create|data create]] command * ''(create_foo.sql@howto)@sqlite'' is a [[docs:resource:script_selector|script selector]] that select the ''create_foo.sql'' in the [[docs:connection:howto|howto]] connection and executes it in the [[docs:connection:howtos|Sqlite howtos connection]] The list of create script data resources executed: uri ----------------------------- (create_foo.sql@howto)@sqlite ==== Check the metadata ==== Check the metadata with the [[docs:tabli:data:struct|tabli data meta]] command tabli data struct foo@sqlite Position Column Name Data Type Primary Key Not Null Auto Increment Description -------- ----------- --------- ----------- -------- -------------- ----------- 1 bar integer x false ==== Next ==== You can also create a table and its dependencies (foreign tables) at once with the [[docs:tabli:data:create|tabli data create command]]. \\ \\ [[howto:database:tabli_create_table_with_dependencies|How to copy a star/snowflake schema ?]]