橸䆹螘螺婘PostgreSQL婺套嘘录傺婔婻桄䔇昄扞康 PostgreSQL柊冕婴䓉桹嚟录傺婔婻桄䔇昄扞康
嘪䫘CREATE DATABASE䔇SQL变傴㔗
嘪䫘createdb䔇婔婻变傴臯埇欓臯桺傽㔗 www.gitbook.net
臖变傴儖录傺婔婻昄扞康PostgreSQL䔇shell柊䴺严嘖嘹庫臖橬锗嘷䔇溄鍊準录傺昄扞康㔗邻螴愙喕婋录傺桄䔇昄扞康儖锔誺噋锖湺庖係䂘昄扞康template1㔗
CREATE DATABASE臺埖䔇嘺橸臺濘套婋 gitbook.net
CREATE DATABASE dbname; www.gitbook.net
噽婺dbname滇襕录傺䔇昄扞康䔇劉䓄㔗
婋麵滇婔婻䞔剘䔇冋床認儖录傺testdb 婘PostgreSQL昇嚟 gitbook.net
postgres=# CREATE DATABASE testdb; postgres-#gitbook.net
PostgreSQL变傴臯埇欓臯createdb滇滇SQL变傴CREATE DATABASE婔婻寙輙単㔗溴变傴启SQL变傴CREATE DATABASE幋閘嫇婔䔇寺彆滇嬉蔙埇傖䕘毖婘变傴臯婺誊臯垄噕螩䔇濘麪赆時媹彄昄扞康婺噘鄘婘婔婻变傴㔗
www.gitbook.net
createdb臺濘套婋欔䴺 www.gitbook.net
createdb [option...] [dbname [description]]gitbook.net
婋臘彖庺庖埗昄埪垄傸䔇柟誄㔗
埗昄劉䓄 | 柟誄 |
---|---|
dbname | The name of a database to create. |
description | Specifies a comment to be associated with the newly created database. |
options | command-line arguments which createdb accepts. |
锬釹 | 柟誄 |
---|---|
-D tablespace | Specifies the default tablespace for the database. |
-e | Echo the commands that createdb generates and sends to the server. |
-E encoding | Specifies the character encoding scheme to be used in this database. |
-l locale | Specifies the locale to be used in this database. |
-T template | Specifies the template database from which to build this database. |
--help | Show help about dropdb command line arguments, and exit. |
-h host | Specifies the host name of the machine on which the server is running. |
-p port | Specifies the TCP port or the local Unix domain socket file extension on which the server is listening for connections. |
-U username | User name to connect as. |
-w | Never issue a password prompt. |
-W | Force createdb to prompt for a password before connecting to a database. |
欷嚔变傴柊䴺严䇽劯寂滇PostgreSQL垬輙欔婘䔇䕞嘘㔗誕噖彄bin䕞嘘欓臯婋麵䔇变傴录傺婔婻昄扞康㔗
www.gitbook.net
createdb -h localhost -p 5432 -U postgress testdb password ******www.gitbook.net
婪麵䔇变傴嚔柊䴺Postgres䔇邻螴䔇PostgreSQL䞇䊖䫘潙䔇凖乕傖冪柊冕凖乕启䂓䂺录傺桄䔇昄扞康㔗 gitbook.net
婔斥录傺昄扞康施埇傖嘪䫘婪誄桹濘埇傖演昖垄婘彖臘婺䔇昄扞康嘪䫘\l剿埉桩亪el变傴套婋 gitbook.net
postgres-# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+---------+-------+----------------------- postgres | postgres | UTF8 | C | C | template0 | postgres | UTF8 | C | C | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | C | C | =c/postgres + | | | | | postgres=CTc/postgres testdb | postgres | UTF8 | C | C | (4 rows) postgres-# www.gitbook.net