PostgreSQL 選擇數據庫


數據庫的命令窗口

PostgreSQL 命令窗口中,我們可以命令提示符后面輸入 SQL 語句:

postgres=#

使用 \l 用於查看已經存在的數據庫:

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

接下來我們可以使用 \c + 數據庫名 來進入數據庫:

postgres=# \c runoobdb
You are now connected to database "runoobdb" as user "postgres".
runoobdb=# 

系統命令行窗口

在系統的命令行查看,我么可以在連接數據庫后面添加數據庫名來選擇數據庫:

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

pgAdmin 工具

pgAdmin 工具更簡單了,直接點擊數據庫選擇就好了,還可以查看一些數據庫額外的信息:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM