小编给大家分享一下PostgreSQL切换数据库的方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

PostgreSQL怎么切换数据库

PostgreSQL切换数据库使用\c命令。

命令格式:

切换数据库:\c [database_name]

切换用户:\c - [user_name]

1、先连上用户postgres、数据库postgres

$su-postgresLastlogin:WedMar113:16:48CST2017onpts/1-bash-4.2$psqlpsql(9.2.18)Type"help"forhelp.postgres=#

2、切换数据库

postgres=#\czzj_db;Youarenowconnectedtodatabase"zzj_db"asuser"postgres".zzj_db=#

3、切换用户

zzj_db=#\c-zzj_user;Passwordforuserzzj_user:Youarenowconnectedtodatabase"zzj_db"asuser"zzj_user".zzj_db=>

看完了这篇文章,相信你对PostgreSQL切换数据库的方法有了一定的了解,想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!