Inside psql
, you always have one active database, where you are “into”. By default it’s the one you connect to in the first place. When you run:
在psql
,您始终只有一个活动数据库,您可以在其中“进入”。 默认情况下,它是您首先连接的那个。 运行时:
psql postgres
you’ll connect to the postgres
database.
您将连接到postgres
数据库。
To switch database, use the \connect
command, or \c
:
要切换数据库,请使用\connect
命令或\c
:
PostgreSQL will close the connection to the previous database you were connected to, and will connect to the new one you specified.
PostgreSQL将关闭与您以前连接的数据库的连接,并将连接到您指定的新数据库。
翻译自: https://flaviocopes.com/postgres-how-to-switch-database/