create_database.7

来自「PostgreSQL 8.2中增加了很多企业用户所需要的功能和性能上的提高,其开」· 7 代码 · 共 141 行

7
141
字号
.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $.TH "CREATE DATABASE" "" "2008-01-03" "SQL - Language Statements" "SQL Commands".SH NAMECREATE DATABASE \- create a new database.SH SYNOPSIS.sp.nfCREATE DATABASE \fIname\fR    [ [ WITH ] [ OWNER [=] \fIdbowner\fR ]           [ TEMPLATE [=] \fItemplate\fR ]           [ ENCODING [=] \fIencoding\fR ]           [ TABLESPACE [=] \fItablespace\fR ]           [ CONNECTION LIMIT [=] \fIconnlimit\fR ] ].sp.fi.SH "DESCRIPTION".PP\fBCREATE DATABASE\fR creates a newPostgreSQL database..PPTo create a database, you must be a superuser or have the specialCREATEDB privilege.See CREATE USER [\fBcreate_user\fR(7)]..PPNormally, the creator becomes the owner of the new database.Superusers can create databases owned by other users, by using theOWNER clause. They can even create databases owned byusers with no special privileges. Non-superusers with CREATEDBprivilege can only create databases owned by themselves..PPBy default, the new database will be created by cloning the standardsystem database template1. A different template can bespecified by writing TEMPLATE\fIname\fR. In particular,by writing TEMPLATE template0, you can create a virgindatabase containing only the standard objects predefined by yourversion of PostgreSQL. This is usefulif you wish to avoid copyingany installation-local objects that may have been added totemplate1..SH "PARAMETERS".TP\fB\fIname\fB\fRThe name of a database to create..TP\fB\fIdbowner\fB\fRThe name of the database user who will own the new database,or DEFAULT to use the default (namely, theuser executing the command)..TP\fB\fItemplate\fB\fRThe name of the template from which to create the new database,or DEFAULT to use the default template(template1)..TP\fB\fIencoding\fB\fRCharacter set encoding to use in the new database. Specifya string constant (e.g., 'SQL_ASCII'),or an integer encoding number, or DEFAULTto use the default encoding (namely, the encoding of thetemplate database). The character sets supported by thePostgreSQL server are described inin the documentation..TP\fB\fItablespace\fB\fRThe name of the tablespace that will be associated with thenew database, or DEFAULT to use thetemplate database's tablespace. Thistablespace will be the default tablespace used for objectscreated in this database. SeeCREATE TABLESPACE [\fBcreate_tablespace\fR(7)]for more information..TP\fB\fIconnlimit\fB\fRHow many concurrent connections can be madeto this database. -1 (the default) means no limit..PPOptional parameters can be written in any order, not only the orderillustrated above..PP.SH "NOTES".PP\fBCREATE DATABASE\fR cannot be executed inside a transactionblock..PPErrors along the line of ``could not initialize database directory''are most likely related to insufficient permissions on the datadirectory, a full disk, or other file system problems..PPUse DROP DATABASE [\fBdrop_database\fR(7)] to remove a database..PPThe program createdb [\fBcreatedb\fR(1)] is awrapper program around this command, provided for convenience..PPAlthough it is possible to copy a database other than template1by specifying its name as the template, this is not (yet) intended asa general-purpose ``\fBCOPY DATABASE\fR'' facility.The principal limitation is that no other sessions can be connected tothe template database while it is being copied. \fBCREATEDATABASE\fR will fail if any other connection exists when it starts;otherwise, new connections to the template database are locked outuntil \fBCREATE DATABASE\fR completes.See in the documentation for more information..PPThe CONNECTION LIMIT option is only enforced approximately;if two new sessions start at about the same time when just oneconnection ``slot'' remains for the database, it is possible thatboth will fail. Also, the limit is not enforced against superusers..SH "EXAMPLES".PPTo create a new database:.sp.nfCREATE DATABASE lusiadas;.sp.fi.PPTo create a database sales owned by user salesappwith a default tablespace of salesspace:.sp.nfCREATE DATABASE sales OWNER salesapp TABLESPACE salesspace;.sp.fi.PPTo create a database music which supports the ISO-8859-1 character set:.sp.nfCREATE DATABASE music ENCODING 'LATIN1';.sp.fi.SH "COMPATIBILITY".PPThere is no \fBCREATE DATABASE\fR statement in the SQLstandard. Databases are equivalent to catalogs, whose creation isimplementation-defined..SH "SEE ALSO"ALTER DATABASE [\fBalter_database\fR(7)], DROP DATABASE [\fBdrop_database\fR(l)]

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?