14
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Herokuでデータベース(PostgreSQL)に接続する方法

Posted at

#接続コマンド

ターミナル
$ heroku pg:psql

ターミナル
psql (9.4.3, server 9.4.5)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.

your-app-name::DATABASE=> 

が表示されればOK

#SQL文の実行
文末のセミコロン;を忘れがちなので注意。
例えばテーブルの中身を全件表示させたい時は

ターミナル
your-app-name::DATABASE=> select * from テーブル名;

 id |         title          |         created_at         |         updated_at         
----+------------------------+----------------------------+----------------------------
  1 | hogehoge1              | 2015-07-11 03:01:41.459369 | 2015-07-11 19:30:38.917108
  2 | hogehoge2              | 2015-09-13 03:01:41.459369 | 2015-09-13 19:30:38.917108
  3 | hogehoge3              | 2015-09-23 03:01:41.459369 | 2015-09-24 19:30:38.917108

(3 rows)

#終了コマンド

ターミナル
your-app-name::DATABASE=> \q
14
18
0

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
14
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?