0

I want to upload a .sql or .xml file in postgresql database using terminal. I saw several solution as I linked followed, but unfortunately none of them works.

It would be nice to get an example. I'm using psql (PostgreSQL) 9.1.5. in Linux environment. Thanks in advance. Possible duplicate: Link-1, Link-2,Link-3, Link-4

0

1 Answer 1

-1

If the .sql file is simply text with with SQL queries in it, then the proper way is:

psql -U some_username -d some_database -f name_of_the_file

What the .xml file is - I don't know. As far as I know, no native PostgreSQL tools produce XML dumps of database.

If the above wouldn't work, show us part of the file, how you ran it, and what did you get.

Sign up to request clarification or add additional context in comments.

9 Comments

My database structure is as this link: codepad.org/AtYLV5on I tried with the command you suggested but it does not even work. FYI, first I connected with the specific database ( command \c database_name) where I want to import all the tables and then I run your command. I dont even get any error message. Another info, I can run other command like create table or insert in the table using the postgreysql command.
Sorry, but I dont understand your comment. \c is command within psql. And I showed how to run psql with file from shell.
Regarding the name_of_the_file parameter: don't I have to locate the file where it is in my machine. Yes, I run postgreysql command where this file is located. Thanks.
1. It's PostgreSQL, not "postgreysql". 2. I have absolutely no idea what you mean by "locate the file".
So if I run it from the shell how do I specify the host address ?
|