May 2019
Intermediate to advanced
600 pages
20h 46m
English
The command that executes a single SQL command and prints the output is the easiest, as shown here:
$ psql -c "SELECT current_time" timetz----------------- 18:48:32.484+01(1 row)
The -c command is non-interactive. If we want to execute multiple commands, we can write those commands in a text file and then execute them using the -f option. This command loads a very small and simple set of examples:
$ psql -f examples.sql
It produces the following output when successful:
SETSETSETSETSETSETDROP SCHEMACREATE SCHEMASETSETSETCREATE TABLECREATE TABLECOPY 5COPY 3
The examples.sql script is very similar to a dump file produced by PostgreSQL backup tools, so this type of file and the output it produces are very common. When a command ...
Read now
Unlock full access