postgresql 使用\c 命令切换数据库和用户

来源:互联网 发布:无忧保姆 知乎 编辑:程序博客网 时间:2024/06/03 22:39

命令格式:

切换数据库:\c [database_name]

切换用户:\c - [user_name]


先连上用户postgres、数据库postgres

su - postgres

Last login: Wed Mar 1 13:16:48 CST 2017 on pts/1
-bash-4.2$ psql

psql (9.2.18)
Type "help" for help.

postgres=#

切换数据库

postgres=# \c zzj_db;

You are now connected to database "zzj_db" as user "postgres".

zzj_db=#

切换用户

zzj_db=# \c - zzj_user;

Password for user zzj_user:

You are now connected to database "zzj_db" as user "zzj_user".

zzj_db=> 



原创粉丝点击