Обсуждение: .dmp files in postgresql
Hi list,
I have got two files (template1.dmp, example1.dmp) and I want to open them in postgresql, I tried the following commands:
- Import template1 :
* createdb -U postgres template1
* psql -U postgres template1 < template1.dmp
- Create the sample of the database:
* createdb -U postgres example1
* psql -U postgres example1 < example1.dmp
I've got no error reported by postgres but nothing happened either.
How should I proceed exactly? Sorry I'm a newbie with PostgreSQL :)
Regards!
On 25 November 2011 20:04, Alpha Beta <dzjitaru@gmail.com> wrote: > Hi list, > I have got two files (template1.dmp, example1.dmp) and I want to open them > in postgresql, I tried the following commands: > - Import template1 : > * createdb -U postgres template1 > * psql -U postgres template1 < template1.dmp > - Create the sample of the database: > * createdb -U postgres example1 > * psql -U postgres example1 < example1.dmp > I've got no error reported by postgres but nothing happened either. > How should I proceed exactly? Sorry I'm a newbie with PostgreSQL :) I'm assuming this is a custom-format file, which is a binary file. You need to use pg_restore to restore the file: For example: pg_restore -d example1 example1.dmp This is because the file is no in plain format. Read the documentation for more information on the output of pg_dump: http://www.postgresql.org/docs/current/static/app-pgdump.html Regards Thom
While you say, I opened the file with bloc note and I noticed that it's not a binary file but plain with SQL commands and so on.
I tried what you said also but didn't work.
Any suggestion? or maybe the commands I'm using doesn't find the path for the 2 files?
2011/11/25 Thom Brown <thom@linux.com>
I'm assuming this is a custom-format file, which is a binary file.On 25 November 2011 20:04, Alpha Beta <dzjitaru@gmail.com> wrote:
> Hi list,
> I have got two files (template1.dmp, example1.dmp) and I want to open them
> in postgresql, I tried the following commands:
> - Import template1 :
> * createdb -U postgres template1
> * psql -U postgres template1 < template1.dmp
> - Create the sample of the database:
> * createdb -U postgres example1
> * psql -U postgres example1 < example1.dmp
> I've got no error reported by postgres but nothing happened either.
> How should I proceed exactly? Sorry I'm a newbie with PostgreSQL :)
You need to use pg_restore to restore the file:
For example:
pg_restore -d example1 example1.dmp
This is because the file is no in plain format. Read the
documentation for more information on the output of pg_dump:
http://www.postgresql.org/docs/current/static/app-pgdump.html
Regards
Thom
On 25 November 2011 20:31, Alpha Beta <dzjitaru@gmail.com> wrote: > While you say, I opened the file with bloc note and I noticed that it's not > a binary file but plain with SQL commands and so on. > I tried what you said also but didn't work. > Any suggestion? or maybe the commands I'm using doesn't find the path for > the 2 files? If it couldn't find the file, you'd receive an error message. How do you know nothing happened? Did you check the database you loaded the file into for the objects it's supposed to create? From looking at the files, what do they create/insert etc? So when you loaded the example1.dmp file into the example1 database, did you then connect to that database and look for restored items? Regards Thom
On Friday, November 25, 2011 12:04:38 pm Alpha Beta wrote: > Hi list, > > I have got two files (template1.dmp, example1.dmp) and I want to open them > in postgresql, I tried the following commands: > > - Import *template1 *: > * createdb -U postgres template1 > * psql -U postgres template1 < template1.dmp > > - Create the sample of the database: > * createdb -U postgres example1 > * psql -U postgres example1 < example1.dmp > > I've got no error reported by postgres but nothing happened either. > How should I proceed exactly? Sorry I'm a newbie with PostgreSQL :) How where the *.dmp files created? Also from below you might want to use -f to designate the file: http://www.postgresql.org/docs/9.0/interactive/app-psql.html " -f filename --file filename Use the file filename as the source of commands instead of reading commands interactively. After the file is processed, psql terminates. This is in many ways equivalent to the internal command \i. If filename is - (hyphen), then standard input is read. Using this option is subtly different from writing psql < filename. In general, both will do what you expect, but using -f enables some nice features such as error messages with line numbers. There is also a slight chance that using this option will reduce the start-up overhead. On the other hand, the variant using the shell's input redirection is (in theory) guaranteed to yield exactly the same output you would have received had you entered everything by hand. " > > Regards! -- Adrian Klaver adrian.klaver@gmail.com