在PostgreSQL中,可以使用CREATE DATABASE命令創(chuàng)建數(shù)據(jù)庫。
語法:
CREATE DATABASE database_name;
這里,database_name是指定要創(chuàng)建的數(shù)據(jù)庫的名稱。
在您的系統(tǒng)中安裝PostgreSQL后,打開開始菜單,然后單擊pgAdmin。會得到一個這樣的頁面:

打開pgAdmin,第一次打開可能需要你輸入密碼,結果如下 -

右鍵單擊PostgreSQL 9.6并將PostgreSQL連接到本地主機服務器。
右鍵單擊數(shù)據(jù)庫(Databases),轉到新數(shù)據(jù)庫,將出現(xiàn)一個彈出框,如下圖所示 -
然后鍵入您要的數(shù)據(jù)庫名稱,這里創(chuàng)建的數(shù)據(jù)庫名稱是:yiibai_db,如下圖所示 -

點擊保存(Save)就可以了。
創(chuàng)建新的數(shù)據(jù)庫(yiibai_db)如下圖所示 -

打開SQL Shell(psql),執(zhí)行以下創(chuàng)建語句 -
create database testdb;
執(zhí)行結果如下 -

查看數(shù)據(jù)庫 -
postgres=# \l
數(shù)據(jù)庫列表
名稱 | 擁有者 | 字元編碼 | 校對規(guī)則 | Ctype | 存取權限
-----------+----------+----------+--------------------------------+--------------------------------+-----------------------
postgres | postgres | UTF8 | Chinese (Simplified)_China.936 | Chinese (Simplified)_China.936 |
template0 | postgres | UTF8 | Chinese (Simplified)_China.936 | Chinese (Simplified)_China.936 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | Chinese (Simplified)_China.936 | Chinese (Simplified)_China.936 | =c/postgres +
| | | | | postgres=CTc/postgres
testdb | postgres | UTF8 | Chinese (Simplified)_China.936 | Chinese (Simplified)_China.936 |
yiibai_db | postgres | UTF8 | Chinese (Simplified)_China.936 | Chinese (Simplified)_China.936 |
(5 行記錄)
postgres=#
或者在 pgAdmin 的左側中查看,結果如下 -
