PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔媆誕嬉誕

CREATE DATABASE

劉䓄

CREATE DATABASE -- 录傺婔婻桄昄扞康

臺濘

CREATE DATABASE name
    [ [ WITH ] [ OWNER [=] dbowner ]
           [ TEMPLATE [=] template ]
           [ ENCODING [=] encoding ]
           [ TABLESPACE [=] tablespace ]
           [ CONNECTION LIMIT [=] connlimit ] ]

柟誄

CREATE DATABASE 录傺婔婻桄昄扞康㔗

襕录傺婔婻昄扞康嘹媙釂滇婔婻轙亓䫘潙潡蔙橬䬹枪䔇 CREATEDB 溄鍊㔗埗黙 CREATE USER

锔婩录傺蔙儖潊婺桄昄扞康䔇䞇䊖叻㔗轙亓䫘潙埇傖䫘 OWNER 床埖录傺噽垄䫘潙欔橬䔇昄扞康㔗䫔躿埇傖录傺澇橬䬹枪溄鍊䔇䫘潙欔拖橬䔇昄扞康㔗橬 CREATEDB 溄鍊䔇麂轙亓䫘潙嘪䫘埻脘录傺躻噌嘪䫘䔇昄扞康㔗

䚺䩕施桄昄扞康儖锔誺噋锖湺庖係䂘昄扞康 template1 準录傺㔗埇傖锔誺 TEMPLATE name 毺垔婉劯䔇昇溪㔗儴噽滇䫘 TEMPLATE template0 录傺婔婻冽亇应䔇㔕埻寙拸 PostgreSQL 鵇垔幬䔇湺庖凹茇䔇昄扞康㔗認婻桹濘埇傖镪噉檪傂嘘噾䂟媹噖彄 template1 麯䔇橸婄垬輙凹茇拙蘺彄桄昄扞康㔗

埗昄

name

襕录傺䔇昄扞康劉庖

dbowner

昄扞康䫘潙䔇劉庖傡儖拖橬桄昄扞康潡蔙滇喍 DEFAULT 嘪䫘䚺䩕䫘潙(幘儌滇欓臯变傴䔇䫘潙)㔗

template

昇溪劉(傯巻婻昇溪录傺桄昄扞康)潡蔙䫘 DEFAULT 嘪䫘䚺䩕昇溪(template1)㔗

encoding

录傺桄昄扞康嘪䫘䔇庖严䚡乕㔗埇傖嘪䫘桺橸劉庖(冋套 'SQL_ASCII')㔕昘昄䚡埙㔕DEFAULT(昇䬽昄扞康䔇䚡乕)㔗PostgreSQL 橉媇単櫇毕䔇庖严镖婘誗21.2.1麯柟誄㔗

tablespace

启桄昄扞康噿蕫䔇臘䷺閘劉庖潡蔙䫘 DEFAULT 臘䴺昇䬽昄扞康䔇臘䷺閘㔗認婻臘䷺閘儖潊婺婘認婻昄扞康麯录傺䔇凹茇䔇䚺䩕臘䷺閘㔗埗黙 CREATE TABLESPACE 诙埡敘崔媇敇㔗

connlimit

昄扞康埇傖毖埖崔儏幽埏䔇誂毖㔗-1(䚺䩕)懟叿五澇橬鍊彽㔗

埇锬埗昄埇傖毬傂懟釺废幥喍蔯婉備備滇婪麵滆䴺䔇釺废㔗

濘懟

CREATE DATABASE 婉脘婘庋媇庖麯麵欓臯㔗

䌂嚚"could not initialize database directory"認湙䔇髍臇橔橬埇脘滇啹婺昄扞䕞嘘䔇溄鍊婉崘潡蔙伕䕻悇幋䌂䔇桺傽係䂘閞鵻㔗

嘪䫘 DROP DATABASE 役鍴婔婻昄扞康

䘋废 createdb 滇認婻变傴䔇儕輙嘪䫘敘媹桹冪㔗

儘䞇埇傖锔誺檪昊昄扞康劉弄滯婺昇溪(蔯麂 template1)嘖滇認(誻)婉滇婔婻锔䫘䔇"COPY DATABASE"媘脘㔗婂襕䔇鍊彽滇婘傯昇䬽崉彽䔇施唍婉噕螩橬噽垄嚔臺鷆毖彄昇䬽昄扞康婪㔗套悩婘嚔哋欓臯 CREATE DATABASE 䔇施唍橬噽垄嚔臺溼誂毖婘昇䬽昄扞康婪闼幽儖嚔崌蘖劥彍䕘彄 CREATE DATABASE 垯潊幋劯欉噕螩傺䆋桄䔇嚔臺誂毖㔗埗蓕誗19.3诙埡敘崔媇敇㔗

CONNECTION LIMIT 锬釹埻滇誏嚚婄嚺彽套悩婴婻桄䔇誂毖庹幯劯施埏蕙蔯埻嬷婋婔婻誂毖"擘嘉"庖闼幽冽埇脘婴婻誂毖鄘崌昽㔗劯湙認婻鍊彽幽婉嚺媹婘轙亓䫘潙婪㔗

冋床

录傺婔婻桄昄扞康

CREATE DATABASE lusiadas;

录傺婔婻䫌䫘潙 salesapp 拖橬䔇昄扞康 sales 䚺䩕臘䷺閘滇 salesspace

CREATE DATABASE sales OWNER salesapp TABLESPACE salesspace;

录傺婔婻昄扞康 music 櫇毕 ISO-8859-1 庖严镖

CREATE DATABASE music ENCODING 'LATIN1';

噚垹攓

婘 SQL 湺庖麯澇橬 CREATE DATABASE 臺埖㔗昄扞康京劯庯䕞嘘噽录傺滇䫌垂䯄喿垔䔇㔗

埽蓕

ALTER DATABASE, DROP DATABASE

劯锔饡釕嬉誕
CREATE CONVERSION婪婔亓CREATE DOMAIN