䯄婘嘉䘞饡釕 > 昄扞康 > PostgreSQL > PostgreSQL录傺昄扞康

PostgreSQL录傺昄扞康

準溊䘏䂩昘䊖    䫌 悕垵幥 敘桄䬽橸    敟蓽庺渇

橸䆹螘螺婘PostgreSQL婺套嘘录傺婔婻桄䔇昄扞康 PostgreSQL柊冕婴䓉桹嚟录傺婔婻桄䔇昄扞康

www.gitbook.net

  • 嘪䫘CREATE DATABASE䔇SQL变傴㔗

    gitbook.net

  • 嘪䫘createdb䔇婔婻变傴臯埇欓臯桺傽㔗 www.gitbook.net

嘪䫘CREATE DATABASE

臖变傴儖录傺婔婻昄扞康PostgreSQL䔇shell柊䴺严嘖嘹庫臖橬锗嘷䔇溄鍊準录傺昄扞康㔗邻螴愙喕婋录傺桄䔇昄扞康儖锔誺噋锖湺庖係䂘昄扞康template1㔗

www.gitbook.net

臺濘

CREATE DATABASE臺埖䔇嘺橸臺濘套婋 gitbook.net

CREATE DATABASE dbname; www.gitbook.net 

噽婺dbname滇襕录傺䔇昄扞康䔇劉䓄㔗

www.gitbook.net

冋床

婋麵滇婔婻䞔剘䔇冋床認儖录傺testdb 婘PostgreSQL昇嚟  gitbook.net

postgres=# CREATE DATABASE testdb;
postgres-#  
gitbook.net

嘪䫘createdb䔇变傴

PostgreSQL变傴臯埇欓臯createdb滇滇SQL变傴CREATE DATABASE婔婻寙輙単㔗溴变傴启SQL变傴CREATE DATABASE幋閘嫇婔䔇寺彆滇嬉蔙埇傖䕘毖婘变傴臯婺誊臯垄噕螩䔇濘麪赆時媹彄昄扞康婺噘鄘婘婔婻变傴㔗

www.gitbook.net

臺濘

createdb臺濘套婋欔䴺 www.gitbook.net

createdb [option...] [dbname [description]] 

gitbook.net

埗昄

婋臘彖庺庖埗昄埪垄傸䔇柟誄㔗

www.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.

锬釹

婋臘彖庺庖变傴臯埗昄CREATEDB毖櫽
gitbook.net

锬釹 柟誄
-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 
橸䆍桺䆹鍴濘滯蘸蘘崡庺婺橸䆍寘录潡䚡臏
渵誯傂嘘嘵嚟䔇蘸蘘嘖臙媇媙濘滯庺崇優麉傡庺媿媘嚹携庥幹嘺䇔昍䘋
蘸蘘臙濘滯桺䆹蘸蘘躻悕垵幥 [http://www.gitbook.net]
橸桺湺鵻PostgreSQL录傺昄扞康
蘸蘘臙媺䘍寘桺鷆毖:http://www.gitbook.net/html/postgresql/2013/080436.html
婪婔䇺PostgreSQL昄扞䌂傋      婋婔䇺PostgreSQL锬拷昄扞康