# 控制台指令
su - postgres
psql
\q 退出控制台
\password 設定密碼
\h 檢視SQL指令的解釋,比如\h select。
\? 檢視psql指令清單。
\l 列出所有資料庫。
\c [database_name]:連接配接其他資料庫。
\d 列出目前資料庫的所有表格。
\d [table_name]:列出某一張表格的結構。
\du 列出所有使用者。
\e 打開文本編輯器。
\conninfo 列出目前資料庫和連接配接的資訊。
# 登陸資料庫
psql -U postgres -d dbname -h 127.0.0.1 -p 5432
-U 指定使用者
-d 指定資料庫
-h 指定伺服器
-p 指定端口
example:
psql -U postgres -d freeswitch -h 127.0.0.1 -p 5432
# 資料庫備份
pg_dump dbname > outfile
pg_dump -U postgres -h 127.0.0.1 -p 5432 freeswitch > outfile
# 查詢資料庫位置
select oid,datname from pg_database;
------------------------
oid | datname
-------+------------
1 | template1
12865 | template0
12870 | postgres
16384 | freeswitch
(4 行記錄)
--------------------
#确認存儲位置
ls /var/lib/pgsql/9.2/data/base/16384/
本文轉自 tanzhenchao 51CTO部落格,原文連結:http://blog.51cto.com/cmdschool/1957224,如需轉載請自行聯系原作者