Jose Cabrera Zuniga
Jose Cabrera Zuniga

Reputation: 2627

Uploading tables and their rows to a postgress Schema from terminal

In PostgresQL, to upload tables and their rows to the public schema within my database called myDB I can use a command like:

psql -h $MYHOST -U postgres -p 5432 myDB < dbinfo.sql

This time, I need also to specify the schema that will receive the tables and their rows from dbinfo.sql (the create and insert commands do not have qualified names)

Can someone tell me how to do this? Thx

Upvotes: 0

Views: 12

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 247370

Use the options -c and -f to specify both an SQL statement and a script:

psql -h $MYHOST -U postgres -p 5432 myDB -c 'SET search_path=aschema' -f dbinfo.sql

Upvotes: 1

Related Questions