PostgreSQL运维命令整理
# 控制台命令 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 -U 指定用户 -h 指定服务器 -p 指定端口 example: 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/ 参阅文档 ==================== http://www.ruanyifeng.com/blog/2013/12/getting_started_with_postgresql.html (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |