create_schema.7

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

7
119
字号
.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $.TH "CREATE SCHEMA" "" "2008-01-03" "SQL - Language Statements" "SQL Commands".SH NAMECREATE SCHEMA \- define a new schema.SH SYNOPSIS.sp.nfCREATE SCHEMA \fIschemaname\fR [ AUTHORIZATION \fIusername\fR ] [ \fIschema_element\fR [ ... ] ]CREATE SCHEMA AUTHORIZATION \fIusername\fR [ \fIschema_element\fR [ ... ] ].sp.fi.SH "DESCRIPTION".PP\fBCREATE SCHEMA\fR enters a new schemainto the current database.The schema name must be distinct from the name of any existing schemain the current database..PPA schema is essentially a namespace:it contains named objects (tables, data types, functions, and operators)whose names may duplicate those of other objects existing in otherschemas. Named objects are accessed either by ``qualifying''their names with the schema name as a prefix, or by setting a searchpath that includes the desired schema(s). A CREATE commandspecifying an unqualified object name creates the objectin the current schema (the one at the front of the search path,which can be determined with the function \fBcurrent_schema\fR)..PPOptionally, \fBCREATE SCHEMA\fR can include subcommandsto create objects within the new schema. The subcommands are treatedessentially the same as separate commands issued after creating theschema, except that if the AUTHORIZATION clause is used,all the created objects will be owned by that user..SH "PARAMETERS".TP\fB\fIschemaname\fB\fRThe name of a schema to be created. If this is omitted, the user nameis used as the schema name. The name cannotbegin with pg_, as such namesare reserved for system schemas..TP\fB\fIusername\fB\fRThe name of the user who will own the schema. If omitted,defaults to the user executing the command. Only superusersmay create schemas owned by users other than themselves..TP\fB\fIschema_element\fB\fRAn SQL statement defining an object to be created within theschema. Currently, only \fBCREATETABLE\fR, \fBCREATE VIEW\fR, \fBCREATEINDEX\fR, \fBCREATE SEQUENCE\fR, \fBCREATETRIGGER\fR and \fBGRANT\fR are accepted as clauseswithin \fBCREATE SCHEMA\fR. Other kinds of objects maybe created in separate commands after the schema is created..SH "NOTES".PPTo create a schema, the invoking user must have theCREATE privilege for the current database.(Of course, superusers bypass this check.).SH "EXAMPLES".PPCreate a schema:.sp.nfCREATE SCHEMA myschema;.sp.fi.PPCreate a schema for user joe; the schema will also benamed joe:.sp.nfCREATE SCHEMA AUTHORIZATION joe;.sp.fi.PPCreate a schema and create a table and view within it:.sp.nfCREATE SCHEMA hollywood    CREATE TABLE films (title text, release date, awards text[])    CREATE VIEW winners AS        SELECT title, release FROM films WHERE awards IS NOT NULL;.sp.fiNotice that the individual subcommands do not end with semicolons..PPThe following is an equivalent way of accomplishing the same result:.sp.nfCREATE SCHEMA hollywood;CREATE TABLE hollywood.films (title text, release date, awards text[]);CREATE VIEW hollywood.winners AS    SELECT title, release FROM hollywood.films WHERE awards IS NOT NULL;.sp.fi.SH "COMPATIBILITY".PPThe SQL standard allows a DEFAULT CHARACTER SET clausein \fBCREATE SCHEMA\fR, as well as more subcommandtypes than are presently accepted byPostgreSQL..PPThe SQL standard specifies that the subcommands in \fBCREATESCHEMA\fR may appear in any order. The presentPostgreSQL implementation does nothandle all cases of forward references in subcommands; it maysometimes be necessary to reorder the subcommands in order to avoidforward references..PPAccording to the SQL standard, the owner of a schema always ownsall objects within it. PostgreSQLallows schemas to contain objects owned by users other than theschema owner. This can happen only if the schema owner grants theCREATE privilege on his schema to someone else..SH "SEE ALSO"ALTER SCHEMA [\fBalter_schema\fR(7)], DROP SCHEMA [\fBdrop_schema\fR(l)]

⌨️ 快捷键说明

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