建站學院轉(zhuǎn)載 前些天,我在某論壇看到有人問createdb怎么用。我做了一個演示。我現(xiàn)在把我使用的命令貼上來,并加點注釋。希望給對pg有興趣的朋友一點提示。那位朋友說,直接指定創(chuàng)建數(shù)據(jù)庫的名字去創(chuàng)建無法成功,其實,是因為這個朋友沒有指定必須的參數(shù)。pg以默認用戶(同當前操作系統(tǒng)登陸名)登陸,失敗了。
以下為引用的內(nèi)容: C:Documents and SettingsAdministrator>createdb somedb |
createdb 自身帶了很多幫助信息非常有用。
以下為引用的內(nèi)容: C:Documents and SettingsAdministrator>createdb -? createdb 創(chuàng)建一個 PostgreSQL 數(shù)據(jù)庫. 使用方法: createdb [選項]... [數(shù)據(jù)庫名稱] [描述] 選項: -D, --tablespace=TABLESPACE 數(shù)據(jù)庫默認表空間 -E, --encoding=ENCODING 數(shù)據(jù)庫編碼 -O, --owner=OWNER 新數(shù)據(jù)庫的所屬用戶 -T, --template=TEMPLATE 要拷貝的數(shù)據(jù)庫模板 -e, --echo 顯示發(fā)送到服務端的命令 -q, --quiet 不寫任何信息 --help 顯示此幫助信息, 然后退出 --versoin 輸出版本信息, 然后退出 聯(lián)接選項: -h, --host=HOSTNAME 數(shù)據(jù)庫服務器所在機器的主機名或套接字目錄 -p, --port=PORT 數(shù)據(jù)庫服務器端口號 -U, --username=USERNAME 聯(lián)接的用戶名 -W, --password 提示輸入口令 默認情況下, 以當前用戶的用戶名創(chuàng)建數(shù)據(jù)庫. 臭蟲報告至 <pgsql-bugs@postgresql.org>. |
以下為引用的內(nèi)容: C:Documents and SettingsAdministrator>createdb -U wap somedb CREATE DATABASE |
以下為引用的內(nèi)容: C:Documents and SettingsAdministrator>set lang=enu |
以下為引用的內(nèi)容: C:Documents and SettingsAdministrator>psql -U wap Welcome to psql 8.1.4, the PostgreSQL interactive terminal. Type: copyright for distribution terms h for help with SQL commands ? for help with psql commands g or terminate with semicolon to execute query q to quit wap=# Invalid command . Try ? for help. wap=# l List of databases Name | Owner | Encoding ---------------+----------+----------- Administrator | wap | SQL_ASCII mydb | wap | SQL_ASCII postgres | postgres | SQL_ASCII somedb | wap | SQL_ASCII template0 | postgres | SQL_ASCII template1 | postgres | SQL_ASCII wap | wap | UTF8 (7 rows) wap=# |
以下為引用的內(nèi)容:Microsoft Windows XP [版本 5.1.2600] |