加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_宿迁站长网 (https://www.0527zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

PostgreSQL - 选择数据库

发布时间:2022-11-01 14:01:06 所属栏目:Asp教程 来源:互联网
导读: PostgreSQL - 选择数据库
? 上一节下一节 ?
本章介绍了访问数据库的各种方法。 假设我们已经在上一章创建了一个数据库。 您可以使用以下任一方法选择数据库 ?
数据库 SQL 提示符
假设你已经

PostgreSQL - 选择数据库

? 上一节下一节 ?

本章介绍了访问数据库的各种方法。 假设我们已经在上一章创建了一个数据库。 您可以使用以下任一方法选择数据库 ?

数据库 SQL 提示符

假设你已经启动了你的 PostgreSQL 客户端并且你已经登陆了下面的 SQL 提示符 ?

postgres=#

您可以使用 \l 检查可用的数据库列表,即反斜杠 el 命令如下 ?

postgres-# \l
                             List of databases
   Name    |  Owner   | Encoding | Collate | Ctype |   Access privileges   
-----------+----------+----------+---------+-------+-----------------------
 postgres  | postgres | UTF8     | C       | C     | 
 template0 | postgres | UTF8     | C       | C     | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
 template1 | postgres | UTF8     | C       | C     | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
 testdb    | postgres | UTF8     | C       | C     | 
(4 rows)
postgres-# 

现在,键入以下命令以连接/选择所需的数据库; 在这里,我们将连接到 testdb 数据库。

postgres=# \c testdb;
psql (9.2.4)
Type "help" for help.
You are now connected to database "testdb" as user "postgres".
testdb=# 

操作系统命令提示符

您可以在登录数据库时从命令提示符中选择您的数据库。 下面是一个简单的例子 ?

psql -h localhost -p 5432 -U postgress testdb
Password for user postgress: ****
psql (9.2.4)
Type "help" for help.
You are now connected to database "testdb" as user "postgres".
testdb=# 

您现在已登录 PostgreSQL testdb 并准备在 testdb 中执行您的命令。 要退出数据库asp数据库,可以使用命令 \q。

? 上一节下一节 ?

(编辑:云计算网_宿迁站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!