How to change the standard public schema on psql command line

To load the MS Access MSD file into PostgreSQL, enter the following command at the psql command prompt.

mdb-schema xxx.mdb postgres | psql -h xxx -U xxx -W -d xxx 

However, Postgres tables are created by the default public schema. I want to have them under a different scheme ("network"), and not by default ("public"). Could you tell me how to switch from β€œpublic” to β€œnetwork” in this situation?

I appreciate any suggestions.

+4
source share
1 answer

You need to install PGOPTIONS:

 mdb-schema xxx.mdb postgres | PGOPTIONS='-c search_path=network' psql -h xxx -U xxx -W -d xxx 

and here is the proof (set the circuit for test_schema):

 $ PGOPTIONS='-c search_path=test_schema' psql postgres -c 'show search_path' search_path ------------- test_schema (1 row) 

Using PGOPTIONS , you can set (almost) any configuration directive

+12
source

All Articles