psql是PostgreSQL的交互式客户端工具,通过该工具来管理和操作PostgreSQL数据库。
语法格式:psql [参数] [数据库名称[用户名称]]
常用参数:
-h | 数据库服务器主机 | -p | 指定PostgreSQL数据库服务器的端口,如果不指定则默认是5432 | -w | 永远不提示输入口令 | -e | 显示发送给服务器的命令 |
参考实例
连接到数据库template1,并列出服务器上所有的数据库:
[root@linuxcool ~]# psql template1
进入数据库postgres:
psql -U postgres
进入数据库查看:
psql -U postgres
\l |