LoginSignup
118
110

More than 5 years have passed since last update.

postgreSQLにコマンドラインからSQLファイルを実行

Last updated at Posted at 2015-12-01

2通りあるようです。

1 DBログイン後SQLファイルを実行
$ psql -U user_name -d db_name (-h ホスト名) にてDBにログイン
$ postgres=> \i ../dump_in.sql

2 DBに一時的にログインしSQLファイルを実行
$ psql -f ../dump_in.sql -U user_name -d db_name (-h ホスト名)

ちなみにどちらの方法でもDBのユーザに権限がない場合、
「許可がありません」の警告が出て実行できません。

118
110
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
118
110