Tabulify - How to create a table with a CREATE Sql statement file

About

This Howto will show you how to create a SQL table with a SQL DDL file that contains a CREATE SQL statement with the Tabul table create command.

Steps

Start Postgres

The next steps will be using the postgres howto connection.

tabul service start postgres
1 service was started
Name       Type
--------   ------
postgres   docker

  • Ping your connection to check that the database is up.
tabul connection ping postgres
The connection (postgres) has been pinged successfully

The CREATE table statement

We will execute the below SQL Script that is located in the howto connection.

-- Create the foo table statement

create table foo (
  bar integer
)


The data create command

With the tabul data create command, if you use a runtime selector as first argument, the selected runtime are executed.

To execute the previous SQL script, the below the command should be executed:

tabul data create '(create_foo.sql@howto)@postgres'
# The quotes are mandatory because parenthesis have a meaning in Bash (ie they start a subshell)

where:

List of runtime executed
runtime_data_uri                  exit_code   count   latency   data_uri                                                        error_message
-------------------------------   ---------   -----   -------   -------------------------------------------------------------   -------------
(create_foo.sql@howto)@postgres           0       1   0.23s     execute/20251110-204521-829-pipe-anonymous/create_foo.log@tmp

Check the metadata

Check the metadata with the tabul data describe command

tabul data describe foo@postgres
Structure of the resource foo@postgres
position   name   type      precision   scale   primary_key   nullable   autoincrement   comment
--------   ----   -------   ---------   -----   -----------   --------   -------------   -------
1          bar    integer   10          0                     x

Next

You can also create a table and its dependencies (foreign tables) at once with the tabul data create command.

How to copy a star/snowflake schema ?




Related Pages
SQL - Data Definition Language (DDL)

DDL is a sql subset that manages the database metadata. You can execute DDL statements with a SQL Request. CREATE, ALTER, DROP With a DDL, you create a SQL Object with the CREATE...

Task Runner