Exporting data in psql non-interactively

If you're still in psql, you can execute a script by simply typing the following:

i path/to/the/script.sql 

For example:

i code/psql_export.sql

The output will not surprise us, as it will simply state the number of records that were outputted:

COPY 50

If you happen to have already quitted psql, the cmd i equivalent is -f, so the command should look like this:

Psql -h localhost -p 5434 -U postgres -d mastering_postgis -f code/psql_export.sql

Not surprisingly, the cmd output is once again the following:

COPY 50
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset