How to use pg_restore with *.sql file?

Started by Andre Lopesover 15 years ago4 messagesgeneral
Jump to latest
#1Andre Lopes
lopes80andre@gmail.com

Hi,

I have generate an *.sql file with the command:

[quote]
pg_dump -a --inserts databasename > exportfilename.sql
[/quote]

How can I use the pg_restore to import the data to the database?

I have tried:

[quote]
pg_restore -d databasename exportfilename.sql
[/quote]

But without success...

What is the best way to import the *.sql file to the database?

Best Regards,

#2Scott Marlowe
scott.marlowe@gmail.com
In reply to: Andre Lopes (#1)
Re: How to use pg_restore with *.sql file?

On Sat, Sep 25, 2010 at 6:19 AM, Andre Lopes <lopes80andre@gmail.com> wrote:

Hi,

I have generate an *.sql file with the command:

[quote]
pg_dump -a --inserts databasename > exportfilename.sql
[/quote]

How can I use the pg_restore to import the data to the database?

Don't.

Just use psql with plain sql dumps:

psql databasename -f exportfilename.sql

#3Dmitriy Igrishin
dmitigr@gmail.com
In reply to: Andre Lopes (#1)
Re: How to use pg_restore with *.sql file?

Hey Andre,

You should not use pg_restore with plain format dump. Use psql for it.

// Dmitriy.

#4Andre Lopes
lopes80andre@gmail.com
In reply to: Scott Marlowe (#2)
Re: How to use pg_restore with *.sql file?

Thanks a lot! It works.

On Sat, Sep 25, 2010 at 1:23 PM, Scott Marlowe <scott.marlowe@gmail.com>wrote:

Show quoted text

On Sat, Sep 25, 2010 at 6:19 AM, Andre Lopes <lopes80andre@gmail.com>
wrote:

Hi,

I have generate an *.sql file with the command:

[quote]
pg_dump -a --inserts databasename > exportfilename.sql
[/quote]

How can I use the pg_restore to import the data to the database?

Don't.

Just use psql with plain sql dumps:

psql databasename -f exportfilename.sql