PostgreSQL 選擇資料庫
上一章節我們講了如何創建資料庫,接下來我們來討論如何去選擇我們創建的資料庫。
資料庫的命令窗口
PostgreSQL 命令窗口中,我們可以命令提示符後面輸入 SQL 語句:
postgres=#
使用 \l 用於查看已經存在的資料庫:
postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+---------+-------+----------------------- postgres | postgres | UTF8 | C | C | zaixiandb | 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 zaixiandb You are now connected to database "zaixiandb" as user "postgres". zaixiandb=#
系統命令行窗口
在系統的命令行查看,我麼可以在連接資料庫後面添加資料庫名來選擇資料庫:
$ 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 "zaixiandb" as user "postgres". zaixiandb=#
pgAdmin 工具
pgAdmin 工具更簡單了,直接點擊數據庫選擇就好了,還可以查看一些資料庫額外的資訊: