From a4ac2f458e8cb76177254f4bd7bbd885991379af Mon Sep 17 00:00:00 2001 From: "Thomas G. Lockhart" Date: Tue, 6 Jul 1999 17:16:42 +0000 Subject: Fix markup for docbook2man man page generation. No big deal; fixed lots of other markup at the same time. Bigest change: make sure there is no whitespace in front of contents. This will probably help the other output types too. --- doc/src/sgml/ref/create_table.sgml | 1334 +++++++++++++++++------------------- 1 file changed, 631 insertions(+), 703 deletions(-) (limited to 'doc/src/sgml/ref/create_table.sgml') diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index af054782114..9e0732d7297 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -19,10 +19,8 @@ CREATE [ TEMPORARY | TEMP ] TABLE table ( - column type - [ NULL | NOT NULL ] [ UNIQUE ] [ DEFAULT value ] + column type + [ NULL | NOT NULL ] [ UNIQUE ] [ DEFAULT value ] [column_constraint_clause | PRIMARY KEY } [ ... ] ] [, ... ] [, PRIMARY KEY ( column [, ...] ) ] @@ -40,112 +38,96 @@ CREATE [ TEMPORARY | TEMP ] TABLE table - - - - - TEMPORARY - - - + + + + TEMPORARY + + The table is created only for this session, and is automatically dropped on session exit. Existing permanent tables with the same name are not visible while the temporary table exists. - - - - - - - table - - - - The name of a new table to be created. - - - - - - - column - - - - The name of a column. - - - - - - - type - - - - The type of the column. This may include array specifiers. - Refer to the PostgreSQL User's Guide for - further information about data types and arrays. - - - - - - - DEFAULT value - - - - A default value for a column. - See the DEFAULT clause for more information. - - - - - - - column_constraint_clause - - - - The optional column constraint clauses specify a list of integrity - constraints or tests which new or updated entries must satisfy for - an insert or update operation to succeed. Each constraint - must evaluate to a boolean expression. Although SQL92 -requires the column_constraint_clause - to refer to that column only, Postgres - allows multiple columns - to be referenced within a single column constraint. - See the column constraint clause for more information. - - - - - - - table_constraint_clause - - - - The optional table CONSTRAINT clause specifies a list of integrity - constraints which new or updated entries must satisfy for - an insert or update operation to succeed. Each constraint - must evaluate to a boolean expression. Multiple columns - may be referenced within a single constraint. - Only one PRIMARY KEY clause may be specified for a table; - PRIMARY KEY column - (a table constraint) and PRIMARY KEY (a column constraint) are - mutually exclusive.. - See the table constraint clause for more information. - - - + + + - - INHERITS inherited_table - + table + + + The name of a new table to be created. + + + + + + column + + + The name of a column. + + + + + + type + + + The type of the column. This may include array specifiers. + Refer to the PostgreSQL User's Guide for + further information about data types and arrays. + + + + + + DEFAULT value + + + A default value for a column. + See the DEFAULT clause for more information. + + + + + + column_constraint_clause + + + The optional column constraint clauses specify a list of integrity + constraints or tests which new or updated entries must satisfy for + an insert or update operation to succeed. Each constraint + must evaluate to a boolean expression. Although SQL92 + requires the column_constraint_clause + to refer to that column only, Postgres + allows multiple columns + to be referenced within a single column constraint. + See the column constraint clause for more information. + + + + + + table_constraint_clause + + + The optional table CONSTRAINT clause specifies a list of integrity + constraints which new or updated entries must satisfy for + an insert or update operation to succeed. Each constraint + must evaluate to a boolean expression. Multiple columns + may be referenced within a single constraint. + Only one PRIMARY KEY clause may be specified for a table; + PRIMARY KEY column + (a table constraint) and PRIMARY KEY (a column constraint) are + mutually exclusive.. + See the table constraint clause for more information. + + + + + + INHERITS inherited_table The optional INHERITS clause specifies a collection of table @@ -169,7 +151,7 @@ requires the column_constraint_clause - + 1998-09-11 @@ -179,43 +161,43 @@ requires the column_constraint_clause - - - - CREATE - - - - Message returned if table is successfully created. - - - - - - - ERROR - - - - Message returned if table creation failed. - This is usually accompanied by some descriptive text, such as: - -amcreate: "table" relation already exists - - which occurs at runtime, if the table specified already exists - in the database. - - - + + + +CREATE + + + + Message returned if table is successfully created. + + + - - - ERROR: DEFAULT: type mismatched - - - - if data type of default value doesn't match the - column definition's data type. + + +ERROR + + + + Message returned if table creation failed. + This is usually accompanied by some descriptive text, such as: + +ERROR: Relation 'table' already exists + + which occurs at runtime, if the table specified already exists + in the database. + + + + + + +ERROR: DEFAULT: type mismatched + + + + If data type of default value doesn't match the + column definition's data type. @@ -223,7 +205,7 @@ amcreate: "table" relation already - + 1998-09-11 @@ -247,47 +229,46 @@ amcreate: "table" relation already - - 1998-09-11 - - - DEFAULT Clause - - - + + 1998-09-11 + + + DEFAULT Clause + + + DEFAULT value - + 1998-09-11 - Inputs - - - - - - value - + Inputs + + + + + + value + + + The possible values for the default value expression are: + + + + a literal value + + - - The possible values for the default value expression are: - - - - a literal value - - - - - a user function - - - - - a niladic function + + a user function + + + + + a niladic function @@ -306,6 +287,7 @@ DEFAULT value Outputs + None. @@ -314,101 +296,95 @@ DEFAULT value 1998-09-11 - Description - - - The DEFAULT clause assigns a default data value to a column - (via a column definition in the CREATE TABLE statement). - The data type of a default value must match the column definition's - data type. - - - An INSERT operation that includes a column without a specified - default value will assign the NULL value to the column - if no explicit data value is provided for it. - Default literal means - that the default is the specified constant value. - Default niladic-function - or user-function means - that the default - is the value of the specified function at the time of the INSERT. - - - There are two types of niladic functions: - + Description + + + The DEFAULT clause assigns a default data value to a column + (via a column definition in the CREATE TABLE statement). + The data type of a default value must match the column definition's + data type. + + + An INSERT operation that includes a column without a specified + default value will assign the NULL value to the column + if no explicit data value is provided for it. + Default literal means + that the default is the specified constant value. + Default niladic-function + or user-function means + that the default + is the value of the specified function at the time of the INSERT. + + + There are two types of niladic functions: + + + niladic USER + + + + CURRENT_USER / USER + + See CURRENT_USER function + + + + SESSION_USER + + not yet supported + + + + SYSTEM_USER + + not yet supported + + + + + + + niladic datetime + + + + CURRENT_DATE + + See CURRENT_DATE function + + - niladic USER + CURRENT_TIME - - - CURRENT_USER / USER - - See CURRENT_USER function - - - - SESSION_USER - - not yet supported - - - - SYSTEM_USER - - not yet supported - - - + See CURRENT_TIME function - niladic datetime + CURRENT_TIMESTAMP - - - CURRENT_DATE - - See CURRENT_DATE function - - - - CURRENT_TIME - - See CURRENT_TIME function - - - - CURRENT_TIMESTAMP - - See CURRENT_TIMESTAMP function - - - + See CURRENT_TIMESTAMP function + + + - -In the current release (v6.5), Postgres -evaluates all default expressions at the time the table is defined. -Hence, functions which are "non-cacheable" such as - CURRENT_TIMESTAMP may not produce the desired -effect. For the particular case of date/time types, one can work -around this behavior by using - -DEFAULT TEXT 'now' - -instead of - -DEFAULT 'now' - -or - -DEFAULT CURRENT_TIMESTAMP -. -This forces Postgres to consider the constant a string -type and then to convert the value to timestamp at runtime. + + In the current release (v6.5), Postgres + evaluates all default expressions at the time the table is defined. + Hence, functions which are "non-cacheable" such as + CURRENT_TIMESTAMP may not produce the desired + effect. For the particular case of date/time types, one can work + around this behavior by using + DEFAULT TEXT 'now' + instead of + DEFAULT 'now' + or + DEFAULT CURRENT_TIMESTAMP. + This forces Postgres to consider the constant a string + type and then to convert the value to timestamp at runtime. @@ -416,44 +392,45 @@ type and then to convert the value to timestamp at runtime. 1998-09-11 - Usage + Usage + - To assign a constant value as the default for the - columns did and number, - and a string literal to the column did: - - + To assign a constant value as the default for the + columns did and number, + and a string literal to the column did: + + CREATE TABLE video_sales ( did VARCHAR(40) DEFAULT 'luso films', number INTEGER DEFAULT 0, total CASH DEFAULT '$0.0' ); - + - To assign an existing sequence - as the default for the column did, - and a literal to the column name: - - + To assign an existing sequence + as the default for the column did, + and a literal to the column name: + + CREATE TABLE distributors ( did DECIMAL(3) DEFAULT NEXTVAL('serial'), name VARCHAR(40) DEFAULT 'luso films' ); - + - - - - - 1998-09-11 - - + </refsect1> + + <refsect1 id="R1-SQL-COLUMNCONSTRAINT-1"> + <refsect1info> + <date>1998-09-11</date> + </refsect1info> + <title> Column CONSTRAINT Clause - - + + [ CONSTRAINT name ] { [ NULL | NOT NULL ] | UNIQUE | PRIMARY KEY | CHECK - - - - name - - - - An arbitrary name given to the integrity constraint. -If name is not specified, - it is generated from the table and column names, -which should ensure uniqueness for - name. - - - + + + name + + + An arbitrary name given to the integrity constraint. + If name is not specified, + it is generated from the table and column names, + which should ensure uniqueness for + name. + + + - - - NULL - - - -The column is allowed to contain NULL values. This is the default. - - - - - - - NOT NULL - - - -The column is not allowed to contain NULL values. -This is equivalent to the column constraint - CHECK (column NOT NULL). - - - - - - - UNIQUE - - - -The column must have unique values. In Postgres -this is enforced by an implicit creation of a unique index on the table. - - - - - - - PRIMARY KEY - - - - This column is a primary key, which implies that uniqueness is -enforced by the system and that other tables may rely on this column -as a unique identifier for rows. - See PRIMARY KEY for more information. - - - - - - - constraint - - - - The definition of the constraint. - - - - - + + NULL + + + The column is allowed to contain NULL values. This is the default. + + + + + + NOT NULL + + + The column is not allowed to contain NULL values. + This is equivalent to the column constraint + CHECK (column NOT NULL). + + + + + + UNIQUE + + + The column must have unique values. In Postgres + this is enforced by an implicit creation of a unique index on the table. + + + + + + PRIMARY KEY + + + This column is a primary key, which implies that uniqueness is + enforced by the system and that other tables may rely on this column + as a unique identifier for rows. + See PRIMARY KEY for more information. + + + + + + +constraint + + + + The definition of the constraint. + + + + + @@ -612,32 +579,29 @@ as a unique identifier for rows. Outputs + + + status + + + + + +ERROR: ExecAppend: Fail to add null value in not null attribute "column". + + + + This error occurs at runtime if one tries to insert a null value + into a column which has a NOT NULL constraint. + + + + + + + + - - - - status - - - - - - - ERROR: ExecAppend: Fail to add null value in not - null attribute "column". - - - - This error occurs at runtime if one tries to insert a null value - into a column which has a NOT NULL constraint. - - - - - - - - @@ -650,7 +614,7 @@ as a unique identifier for rows. - + 1998-09-11 @@ -658,22 +622,22 @@ as a unique identifier for rows. Usage - + Define two NOT NULL column constraints on the table distributors, one of which being a named constraint: - - - CREATE TABLE distributors ( - did DECIMAL(3) CONSTRAINT no_null NOT NULL, - name VARCHAR(40) NOT NULL - ); + + +CREATE TABLE distributors ( + did DECIMAL(3) CONSTRAINT no_null NOT NULL, + name VARCHAR(40) NOT NULL +); - + 1998-09-11 @@ -688,11 +652,10 @@ as a unique identifier for rows. Inputs + - - CONSTRAINT name - + CONSTRAINT name An arbitrary label given to a constraint. @@ -706,22 +669,20 @@ as a unique identifier for rows. Outputs - - - -status - - - - - - -ERROR: Cannot insert a duplicate key into a unique index. - - - - This error occurs at runtime if one tries to insert a - duplicate value into a column. + + + status + + + + + +ERROR: Cannot insert a duplicate key into a unique index. + + + + This error occurs at runtime if one tries to insert a + duplicate value into a column. @@ -732,10 +693,10 @@ as a unique identifier for rows. - + -Description + Description @@ -747,9 +708,9 @@ Description include a NOT NULL constraint to be included in a UNIQUE constraint. Having more than one null value in a column without a NOT NULL constraint, does not violate a UNIQUE constraint. -(This deviates from the SQL92 definition, but -is a more sensible convention. See the section on compatibility -for more details.). + (This deviates from the SQL92 definition, but + is a more sensible convention. See the section on compatibility + for more details.). Each UNIQUE column constraint must name a column that is @@ -759,68 +720,66 @@ for more details.). Postgres automatically creates a unique - index for each UNIQUE constraint, to assure + index for each UNIQUE constraint, to assure data integrity. See CREATE INDEX for more information. - - -Usage - + + + Usage + - - Defines a UNIQUE column constraint for the table distributors. - UNIQUE column constraints can only be defined on one column - of the table: - - CREATE TABLE distributors ( - did DECIMAL(3), - name VARCHAR(40) UNIQUE - ); + + Defines a UNIQUE column constraint for the table distributors. + UNIQUE column constraints can only be defined on one column + of the table: + +CREATE TABLE distributors ( + did DECIMAL(3), + name VARCHAR(40) UNIQUE +); -which is equivalent to the following specified as a table constraint: - + + which is equivalent to the following specified as a table constraint: + CREATE TABLE distributors ( did DECIMAL(3), name VARCHAR(40), UNIQUE(name) ); - + - + 1998-09-11 - -The CHECK Constraint - - + + The CHECK Constraint + + [ CONSTRAINT name ] CHECK ( condition [, ...] ) - + Inputs - - - - - name - - - - An arbitrary name given to a constraint. + + + + + name + + + An arbitrary name given to a constraint. - - condition - + condition Any valid conditional expression evaluating to a boolean result. @@ -830,7 +789,7 @@ The CHECK Constraint - + 1998-09-11 @@ -839,22 +798,18 @@ The CHECK Constraint Outputs + - - status - + status - + - - - ERROR: ExecAppend: rejected due to CHECK constraint - "table_column". - - + +ERROR: ExecAppend: rejected due to CHECK constraint "table_column". + This error occurs at runtime if one tries to insert an illegal @@ -869,7 +824,7 @@ The CHECK Constraint - + Description @@ -896,15 +851,13 @@ The CHECK Constraint [ CONSTRAINT name ] PRIMARY KEY - + Inputs - -CONSTRAINT name - + CONSTRAINT name An arbitrary name for the constraint. @@ -919,9 +872,9 @@ CONSTRAINT name Outputs - -ERROR: Cannot insert a duplicate key into a unique index. - + +ERROR: Cannot insert a duplicate key into a unique index. + This occurs at run-time if one tries to insert a duplicate value into @@ -936,7 +889,7 @@ CONSTRAINT name Description The PRIMARY KEY column constraint specifies that a column of a table - may contain only unique + may contain only unique (non-duplicate), non-NULL values. The definition of the specified column does not have to include an explicit NOT NULL constraint to be included in a PRIMARY KEY constraint. @@ -955,16 +908,16 @@ CONSTRAINT name Postgres automatically creates - a unique index to assure + a unique index to assure data integrity. (See CREATE INDEX statement) The PRIMARY KEY constraint should name a set of columns that is different from other sets of columns named by any UNIQUE constraint defined for the same table, since it will result in duplication -of equivalent indexes and unproductive additional runtime overhead. -However, Postgres does not specifically -disallow this. + of equivalent indexes and unproductive additional runtime overhead. + However, Postgres does not specifically + disallow this. @@ -979,9 +932,8 @@ disallow this. - [ CONSTRAINT name ] { PRIMARY KEY | UNIQUE } ( column [, ...] ) - [ CONSTRAINT name ] CHECK ( constraint ) +[ CONSTRAINT name ] { PRIMARY KEY | UNIQUE } ( column [, ...] ) +[ CONSTRAINT name ] CHECK ( constraint ) @@ -991,13 +943,12 @@ disallow this. Inputs - + + - - CONSTRAINT name - + CONSTRAINT name An arbitrary name given to an integrity constraint. @@ -1005,9 +956,7 @@ disallow this. - - column [, ...] - + column [, ...] The column name(s) for which to define a unique index @@ -1016,9 +965,7 @@ disallow this. - - CHECK ( constraint ) - + CHECK ( constraint ) A boolean expression to be evaluated as the constraint. @@ -1083,17 +1030,14 @@ disallow this. - [ CONSTRAINT name ] - UNIQUE ( column [, ...] ) +[ CONSTRAINT name ] UNIQUE ( column [, ...] ) Inputs - - CONSTRAINT name - + CONSTRAINT name An arbitrary name given to a constraint. @@ -1101,9 +1045,7 @@ disallow this. - - column - + column A name of a column in a table. @@ -1118,16 +1060,12 @@ disallow this. - - status - + status - - ERROR: Cannot insert a duplicate key into a unique index. - + ERROR: Cannot insert a duplicate key into a unique index This error occurs at runtime if one tries to insert a @@ -1167,11 +1105,11 @@ disallow this. Define a UNIQUE table constraint for the table distributors: - CREATE TABLE distributors ( - did DECIMAL(03), - name VARCHAR(40), - UNIQUE(name) - ); +CREATE TABLE distributors ( + did DECIMAL(03), + name VARCHAR(40), + UNIQUE(name) +); @@ -1186,18 +1124,16 @@ disallow this. - [ CONSTRAINT name ] - PRIMARY KEY ( column [, ...] ) +[ CONSTRAINT name ] PRIMARY KEY ( column [, ...] ) Inputs + - - CONSTRAINT name - + CONSTRAINT name An arbitrary name for the constraint. @@ -1205,9 +1141,7 @@ disallow this. - - column [, ...] - + column [, ...] The names of one or more columns in the table. @@ -1222,9 +1156,7 @@ disallow this. Outputs - - status - + status @@ -1252,7 +1184,9 @@ disallow this. (non duplicate), non-null values. The column definitions of the specified columns do not have to include a NOT NULL constraint to be included in a PRIMARY KEY constraint. - + + + The PRIMARY KEY table constraint is similar to that for column constraints, with the additional capability of encompassing multiple columns. @@ -1261,9 +1195,9 @@ disallow this. information. - + - + @@ -1271,107 +1205,116 @@ disallow this. Usage - Create table films and table distributors - - - CREATE TABLE films ( - code CHARACTER(5) CONSTRAINT firstkey PRIMARY KEY, - title CHARACTER VARYING(40) NOT NULL, - did DECIMAL(3) NOT NULL, - date_prod DATE, - kind CHAR(10), - len INTERVAL HOUR TO MINUTE - ); - + Create table films and table distributors: - - CREATE TABLE distributors ( - did DECIMAL(03) PRIMARY KEY DEFAULT NEXTVAL('serial'), - name VARCHAR(40) NOT NULL CHECK (name <> '') - ); - + +CREATE TABLE films ( + code CHARACTER(5) CONSTRAINT firstkey PRIMARY KEY, + title CHARACTER VARYING(40) NOT NULL, + did DECIMAL(3) NOT NULL, + date_prod DATE, + kind CHAR(10), + len INTERVAL HOUR TO MINUTE +); + - - Create a table with a 2-dimensional array + +CREATE TABLE distributors ( + did DECIMAL(03) PRIMARY KEY DEFAULT NEXTVAL('serial'), + name VARCHAR(40) NOT NULL CHECK (name <> '') +); + - + + + Create a table with a 2-dimensional array: + + CREATE TABLE array ( vector INT[][] ); - - + + + Define a UNIQUE table constraint for the table films. UNIQUE table constraints can be defined on one or more - columns of the table + columns of the table: + + +CREATE TABLE films ( + code CHAR(5), + title VARCHAR(40), + did DECIMAL(03), + date_prod DATE, + kind CHAR(10), + len INTERVAL HOUR TO MINUTE, + CONSTRAINT production UNIQUE(date_prod) +); + - - CREATE TABLE films ( - code CHAR(5), - title VARCHAR(40), - did DECIMAL(03), - date_prod DATE, - kind CHAR(10), - len INTERVAL HOUR TO MINUTE, - CONSTRAINT production UNIQUE(date_prod) - ); - - Define a CHECK column constraint. + Define a CHECK column constraint: + + +CREATE TABLE distributors ( + did DECIMAL(3) CHECK (did > 100), + name VARCHAR(40) +); + - - CREATE TABLE distributors ( - did DECIMAL(3) CHECK (did > 100), - name VARCHAR(40) - ); - - + - Define a CHECK table constraint + Define a CHECK table constraint: + + +CREATE TABLE distributors ( + did DECIMAL(3), + name VARCHAR(40) + CONSTRAINT con1 CHECK (did > 100 AND name > '') +); + - - CREATE TABLE distributors ( - did DECIMAL(3), - name VARCHAR(40) - CONSTRAINT con1 CHECK (did > 100 AND name > '') - ); - - + Define a PRIMARY KEY table constraint for the table films. PRIMARY KEY table constraints can be defined on one or more - columns of the table + columns of the table: + + +CREATE TABLE films ( + code CHAR(05), + title VARCHAR(40), + did DECIMAL(03), + date_prod DATE, + kind CHAR(10), + len INTERVAL HOUR TO MINUTE, + CONSTRAINT code_title PRIMARY KEY(code,title) +); + - - CREATE TABLE films ( - code CHAR(05), - title VARCHAR(40), - did DECIMAL(03), - date_prod DATE, - kind CHAR(10), - len INTERVAL HOUR TO MINUTE, - CONSTRAINT code_title PRIMARY KEY(code,title) - ); - - + Defines a PRIMARY KEY column constraint for table distributors. PRIMARY KEY column constraints can only be defined on one column - of the table (the following two examples are equivalent) + of the table (the following two examples are equivalent): + + +CREATE TABLE distributors ( + did DECIMAL(03), + name CHAR VARYING(40), + PRIMARY KEY(did) +); + + + +CREATE TABLE distributors ( + did DECIMAL(03) PRIMARY KEY, + name VARCHAR(40) +); + - - CREATE TABLE distributors ( - did DECIMAL(03), - name CHAR VARYING(40), - PRIMARY KEY(did) - ); - - CREATE TABLE distributors ( - did DECIMAL(03) PRIMARY KEY, - name VARCHAR(40) - ); - @@ -1401,18 +1344,19 @@ disallow this. SQL92 - In addition to the normal CREATE TABLE, SQL92 also defines a - CREATE TEMPORARY TABLE statement: - + In addition to the locally-visible temporary table, SQL92 also defines a + CREATE GLOBAL TEMPORARY TABLE statement, and optionally an + ON COMMIT clause: - CREATE [ {GLOBAL | LOCAL} ] TEMPORARY TABLE table ( - column type [DEFAULT value] [CONSTRAINT column_constraint] [, ...] ) - [CONSTRAINT table_constraint ] - [ ON COMMIT {DELETE | PRESERVE} ROWS ] +CREATE GLOBAL TEMPORARY TABLE table ( column type [ + DEFAULT value ] [ CONSTRAINT column_constraint ] [, ...] ) + [ CONSTRAINT table_constraint ] [ ON COMMIT { DELETE | PRESERVE } ROWS ] + + - For temporary tables, the CREATE TEMPORARY TABLE statement - names a new table and defines the table's columns and + For temporary tables, the CREATE GLOBAL TEMPORARY TABLE statement + names a new table visible to other clients and defines the table's columns and constraints. @@ -1423,26 +1367,16 @@ disallow this. To create a temporary table: + + +CREATE TEMPORARY TABLE actors ( + id DECIMAL(03), + name VARCHAR(40), + CONSTRAINT actor_id CHECK (id < 150) +) ON COMMIT DELETE ROWS; + - - CREATE TEMPORARY TABLE actors ( - id DECIMAL(03), - name VARCHAR(40), - CONSTRAINT actor_id CHECK (id < 150) - ) ON COMMIT DELETE ROWS - - - Temporary tables are not currently available - in Postgres. - - - In the current release of Postgres - (v6.5), to create a temporary - table you must create and drop the table by explicit commands. - - - - + 1998-09-11 @@ -1454,23 +1388,24 @@ disallow this. SQL92 specifies some additional capabilities for UNIQUE: - Table Constraint definition + Table Constraint definition: + + +[ CONSTRAINT name ] UNIQUE ( column [, ...] ) + [ { INITIALLY DEFERRED | INITIALLY IMMEDIATE } ] + [ [ NOT ] DEFERRABLE ] + - - [ CONSTRAINT name ] - UNIQUE ( column [, ...] ) - [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] - [ [ NOT ] DEFERRABLE ] - + - Column Constraint definition - - - [ CONSTRAINT name ] - UNIQUE + Column Constraint definition: + + +[ CONSTRAINT name ] UNIQUE [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] [ [ NOT ] DEFERRABLE ] - + + @@ -1485,10 +1420,10 @@ disallow this. is a Postgres extension to SQL92 is included for symmetry with the NOT NULL clause. Since it is the default for any column, its presence is simply noise. - - [ CONSTRAINT name ] NULL - - + +[ CONSTRAINT name ] NULL + + @@ -1501,12 +1436,12 @@ disallow this. SQL92 specifies some additional capabilities for NOT NULL: + +[ CONSTRAINT name ] NOT NULL + [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] + [ [ NOT ] DEFERRABLE ] + - - [ CONSTRAINT name ] NOT NULL - [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] - [ [ NOT ] DEFERRABLE ] - - + 1998-09-11 @@ -1562,7 +1497,7 @@ the column. Not our problem... constraint: - CREATE ASSERTION name CHECK ( condition ) +CREATE ASSERTION name CHECK ( condition ) @@ -1571,37 +1506,34 @@ the column. Not our problem... Domain constraint: + + +[ CONSTRAINT name ] CHECK constraint + [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] + [ [ NOT ] DEFERRABLE ] + - - [ CONSTRAINT name ] - CHECK constraint - [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] - [ [ NOT ] DEFERRABLE ] - + Table constraint definition: + + +[ CONSTRAINT name ] { PRIMARY KEY ( column, ... ) | FOREIGN KEY constraint | UNIQUE constraint | CHECK constraint } + [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] + [ [ NOT ] DEFERRABLE ] + - - [ CONSTRAINT name ] - { PRIMARY KEY constraint | - FOREIGN KEY constraint | - UNIQUE constraint | - CHECK constraint } - [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] - [ [ NOT ] DEFERRABLE ] + Column constraint definition: + + +[ CONSTRAINT name ] { NOT NULL | PRIMARY KEY | FOREIGN KEY constraint | UNIQUE | CHECK constraint } + [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] + [ [ NOT ] DEFERRABLE ] + - - [ CONSTRAINT name ] - { NOT NULL constraint | - PRIMARY KEY constraint | - FOREIGN KEY constraint | - UNIQUE constraint | - CHECK constraint } - [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] - [ [ NOT ] DEFERRABLE ] - + A CONSTRAINT definition may contain one deferment attribute clause and/or one initial constraint mode clause, in any order. @@ -1679,24 +1611,23 @@ affect a column or a table. --> table constraint definition: - - - [ CONSTRAINT name ] - CHECK ( VALUE condition ) + +[ CONSTRAINT name ] CHECK ( VALUE condition ) [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] [ [ NOT ] DEFERRABLE ] - + + + column constraint definition: - - [ CONSTRAINT name ] - CHECK ( VALUE condition ) +[ CONSTRAINT name ] CHECK ( VALUE condition ) [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] [ [ NOT ] DEFERRABLE ] + - - + 1998-09-11 @@ -1732,22 +1662,20 @@ affect a column or a table. Table Constraint definition: + +[ CONSTRAINT name ] PRIMARY KEY ( column [, ...] ) + [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] + [ [ NOT ] DEFERRABLE ] + - - [ CONSTRAINT name ] - PRIMARY KEY ( column [, ...] ) - [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] - [ [ NOT ] DEFERRABLE ] - Column Constraint definition: + +[ CONSTRAINT name ] PRIMARY KEY + [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] + [ [ NOT ] DEFERRABLE ] + - - [ CONSTRAINT name ] - PRIMARY KEY - [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] - [ [ NOT ] DEFERRABLE ] - -- cgit v1.2.3