作者:瀚高PG实验室 (Highgo PG Lab)- 徐云鹤
使用psql怎么切换数据库或者用户呢?
通过如下方式可以通过特定用户连接特定数据库:
[highgo@rhel ~]$ psql -d highgo -U highgo
-d就是指定的数据库名,-U就是指定的用户名。
如果通过psql已经连接进来了,我们可以怎么切换呢?
通过如下方式:
highgo=# \c highgo xyh
Password for user xyh:
You are now connected to database "highgo" as user "xyh".
highgo=>
通过\c,后跟数据库和用户名。
\c后什么都不写会显示当前连接信息:
highgo=> \c
You are now connected to database "highgo" as user "xyh".