在MySQL中,我使用use database_name;
psql的等价是什么?
在MySQL中,我使用use database_name;
psql的等价是什么?
当前回答
数据库的\l \c数据库名切换到db \df用于存储在特定数据库中的过程
其他回答
使用psql的元命令\c或\connect [dbname [username] [host] [port]] | conninfo(参见文档)。
示例:\c MyDatabase
注意,\c和\connect元命令是区分大小写的。
您只需输入use [dbName]即可在数据库之间进行切换,而无需重新输入密码。
在PostgreSQL中,你可以使用客户端工具psql的\connect元命令:
\connect DBNAME
简而言之:
\c DBNAME
虽然问题中没有明确说明,但目的是连接到特定的模式/数据库。
另一种选择是直接连接到模式。例子:
Sudo -u postgres PSQL -d my_database_name
来源:man psql:
-d dbname
--dbname=dbname
Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line.
If this parameter contains an = sign or starts with a valid URI prefix (postgresql:// or postgres://), it is treated as a conninfo string. See Section 31.1.1, “Connection Strings”, in the
documentation for more information.
您可以使用\c <database>或\connect <database>连接到数据库。