How to create a SQL view with a CREATE statement file
About
This Howto will show you how to create a SQL View with a SQL file that contains a CREATE SQL statement with the Tabul table create command.
Steps
Prerequisites
You should have Tabulify installed on your computer: Learning Tabulify - Step 1 - Installation
The CREATE View statement
We will execute the below SQL Script that is located in the howto connection.
create view foo as
select "bar"
The data create command
With the tabul data create command, if you use a runtime selector as first argument, the selected script are executed.
To execute the previous SQL script, the below the command should be executed:
tabul data create '(create_view_foo.sql@howto)@sqlite'
# The quotes are only mandatory in bash because parenthesis are a bash token (ie subshell)
where:
- data create is the data create command
- (create_view_foo.sql)@sqlite is a runtime selector that:
- select the create_view_foo.sql in the howto connection
- and executes it in the Sqlite howtos connection
List of runtime executed
runtime_data_uri exit_code count latency data_uri error_message
---------------------------------- --------- ----- ------- ------------------------------------------------------------------ -------------
(create_view_foo.sql@howto)@sqlite 0 1 0.27s execute/20251110-204922-162-pipe-anonymous/create_view_foo.log@tmp
Check the metadata
Check the metadata with the tabul data describe command
tabul data describe foo@sqlite
Structure of the resource foo@sqlite
position name type precision scale primary_key nullable autoincrement comment
-------- ----- ---- --------- ----- ----------- -------- ------------- -------
1 "bar" text 0 0 x