“使用数据库名称” PostgreSQL中的命令 [英] "use database_name" command in PostgreSQL

查看:80
本文介绍了“使用数据库名称” PostgreSQL中的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是PostgreSQL的初学者。

I am beginner to PostgreSQL.

我想从Postgres的查询编辑器连接到另一个数据库,例如 USE 命令。

I want to connect to another database from the query editor of Postgres - like the USE command of MySQL or MS SQL Server.

我通过搜索Internet找到了 \c数据库名称,但是它只能在 psql 。当我从PostgreSQL查询编辑器尝试它时,出现语法错误。

I found \c databasename by searching the Internet, but its runs only on psql. When I try it from the PostgreSQL query editor I get a syntax error.

我必须通过pgscripting更改数据库。有人知道怎么做吗?

I have to change the database by pgscripting. Does anyone know how to do it?

推荐答案

当您与 PostgreSQL 总是到特定的数据库。要访问其他数据库,必须获得新的连接。

When you get a connection to PostgreSQL it is always to a particular database. To access a different database, you must get a new connection.

在psql中使用 \c 关闭旧的数据库连接并使用指定的数据库和/或凭据获取新的连接。您将获得一个全新的后端流程以及所有内容。

Using \c in psql closes the old connection and acquires a new one, using the specified database and/or credentials. You get a whole new back-end process and everything.

这篇关于“使用数据库名称” PostgreSQL中的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆