I am using PostgreSQL 8.4, and I have some *.sql files to import into a database. How can I do so?
相关问题
- How to reimport module with ES6 import
- Django distinct is not working
- PostgreSQL: left outer join syntax
- Connecting Python to a Heroku PostgreSQL DB?
- PostgreSQL - Deleting data that are older than an
相关文章
- postgresql 关于使用between and 中是字符串的问题
- postgresql 月份差计算问题
- Using boolean expression in order by clause
- Table valued Parameter Equivalent in Postgresql
- in redshift postgresql can I skip columns with the
- Oracle equivalent of PostgreSQL INSERT…RETURNING *
- PostgreSQL field data type for IPv4 addresses
- Using prepared statement in stored function
Well, the shortest way I know of, is following:
database_name: Which database should you insert your file data in.
file_path: Absolute path to the file through which you want to perform the importing.
host_name: The name of the host. For development purposes, it is mostly
localhost
.Upon entering this command in console, you will be prompted to enter your password.
Always preferred using a connection service file (lookup/google 'psql connection service file')
Then simply:
Where
yourservicename
is a section name from the service file.in command line first reach the directory where psql is present then write commands like this:
and then press enter psql asks for password give the user password:
then write
then press enter insertion done.
From the command line:
From the
psql
prompt:Note that you may need to import the files in a specific order (for example: data definition before data manipulation). If you've got
bash
shell (GNU/Linux, Mac OS X, Cygwin) and the files may be imported in the alphabetical order, you may use this command:Here's the documentation of the
psql
application (thanks, Frank): http://www.postgresql.org/docs/current/static/app-psql.htmlBe careful with "/" and "\". Even on Windows the command should be in the form: