May 2019
Intermediate to advanced
600 pages
20h 46m
English
This was just one way to define variables. Another is to indicate them in the command line, when running the script:
psql -v tabname=mytab2 -f vartest.sql
Variables can also be set interactively. The following line will prompt the user, and then set the variable to whatever is typed before hitting Enter:
\prompt 'Insert the table name: ' tabname
In the next recipe, we will see how to set variables using a SQL query.
Read now
Unlock full access