如何在heroku中使用pg:psql?

时间:2013-02-05 20:29:39

标签: postgresql heroku ruby-on-rails-3.1

我正试图在heroku终端上检测我的数据库,如下所示:

myapp@ubuntu:~/RubymineProjects/myapp$ heroku pg:info
The plugin heroku-sql-console has been deprecated. Would you like to remove it? (y/N) n
=== HEROKU_POSTGRESQL_JADE_URL (DATABASE_URL)
Plan:        Dev
Status:      available
Connections: 1
PG Version:  9.1.6
Created:     2012-10-10 19:59 UTC
Data Size:   9.1 MB
Tables:      32
Rows:        2802/10000 (In compliance)
Fork/Follow: Unsupported

所以,我试过了:

myapp@ubuntu:~/RubymineProjects/myapp$ heroku pg:psql
The plugin heroku-sql-console has been deprecated. Would you like to remove it? (y/N) n
psql (9.1.7, server 9.1.6)
SSL connection (cipher: **-**-****-**, bits: 256)
Type "help" for help.

我需要列出所有用户记录:

dbfjinfaes61gb=> select * from users
dbfjinfaes61gb-> 

但是上面,没有发生任何事,我在这里缺少什么?

2 个答案:

答案 0 :(得分:37)

在查询结尾处需要分号:

select * from users;

答案 1 :(得分:7)

运行此

heroku pg:psql -c "command" --app "name-app"

样品

heroku pg:psql -c "\?" --app app-sample