From: Bruce Momjian Date: Fri, 14 Apr 2000 21:44:21 +0000 (+0000) Subject: Updates create_function.sgml with fixes for new foreign keys X-Git-Tag: REL7_0~131 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6787c6c9e804cc62dd70b007961f0d102b738b63;p=postgresql Updates create_function.sgml with fixes for new foreign keys --- diff --git a/doc/TODO b/doc/TODO index dcecd7b942..260983352c 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,6 +1,6 @@ TODO list for PostgreSQL ======================== -Last updated: Thu Mar 23 01:35:33 EST 2000 +Last updated: Fri Apr 14 16:07:41 EDT 2000 Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us) @@ -309,6 +309,7 @@ SOURCE CODE * Remove SET KSQO option if OR processing is improved(Tom) * -Pre-generate lex and yacc output so not required for install(Peter E) * Use macros to define NT open() file parameters, remove NT-specific defines +* Change CURRENT to OLD internally for rules --------------------------------------------------------------------------- diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index 9bc0968a43..649ba1f017 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -1,5 +1,5 @@ @@ -97,15 +97,16 @@ CREATE [ TEMPORARY | TEMP ] TABLE tablecolumn_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. + 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. @@ -114,16 +115,16 @@ CREATE [ TEMPORARY | TEMP ] TABLE tabletable_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. + 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. @@ -140,13 +141,6 @@ CREATE [ TEMPORARY | TEMP ] TABLE tablePostgres automatically allows the created table to inherit functions on tables above it in the inheritance hierarchy. - - Aside - - Inheritance of functions is done according - to the conventions of the Common Lisp Object System (CLOS). - - @@ -227,7 +221,7 @@ ERROR: DEFAULT: type mismatched - As of Postgres version 6.0, consistant array dimensions within an + As of Postgres version 6.0, consistent array dimensions within an attribute are not enforced. This will likely change in a future release. @@ -353,13 +347,13 @@ DEFAULT value SESSION_USER - not yet supported + See CURRENT_USER function SYSTEM_USER - not yet supported + See CURRENT_USER function @@ -502,9 +496,9 @@ CREATE TABLE distributors ( 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. + 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. @@ -529,13 +523,12 @@ CREATE TABLE distributors ( - The optional constraint - clauses specify 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. Multiple attributes may be referenced within - a single constraint. The use of PRIMARY KEY - as a table constraint - is mutually incompatible with PRIMARY KEY as a column constraint. + The optional constraint clauses specify 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. Multiple attributes may be referenced within a single + constraint. The use of PRIMARY KEY as a table constraint is mutually + incompatible with PRIMARY KEY as a column constraint. @@ -550,10 +543,9 @@ CREATE TABLE distributors ( - A column constraint is an integrity constraint defined as part - of a column definition, and logically becomes a table - constraint as soon as it is created. The column - constraints available are: + A column constraint is an integrity constraint defined as part of a + column definition, and logically becomes a table constraint as soon + as it is created. The column constraints available are: PRIMARY KEY @@ -563,14 +555,6 @@ CREATE TABLE distributors ( NOT NULL - - - - Postgres now - (new for v7.0) supports - REFERENCES integrity constraints. - - @@ -710,11 +694,11 @@ ERROR: Cannot insert a duplicate key into a unique index. The column definitions of the specified columns do not have to 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.). + 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.). Each UNIQUE column constraint must name a column that is @@ -827,14 +811,13 @@ ERROR: ExecAppend: rejected due to CHECK constraint "matchtype - The type of comparison to do between the table data. There are three - types of matching, MATCH FULL, MATCH PARTIAL, and the unspecified match type - used if no match type is specified. + The type of comparison to do between the table data. There are + three types of matching, MATCH FULL, MATCH PARTIAL, and the + unspecified match type used if no match type is specified. + MATCH PARTIAL is not + currently supported. @@ -988,10 +973,10 @@ ERROR: Cannot insert a duplicate key into a unique index. deleted. There are the following actions. - CASCADE + NO ACTION - Delete any rows referencing the deleted row. + Produce error if foreign key violated. This is the default. @@ -999,31 +984,31 @@ ERROR: Cannot insert a duplicate key into a unique index. RESTRICT - Disallow deletion of rows being referenced. + Same as NO ACTION. - SET NULL + CASCADE - Set the referencing column values to NULL. + Delete any rows referencing the deleted row. - SET DEFAULT + SET NULL - Set the referencing column values to their default value. + Set the referencing column values to NULL. - NO ACTION + SET DEFAULT - Do nothing. + Set the referencing column values to their default value. @@ -1035,16 +1020,16 @@ ERROR: Cannot insert a duplicate key into a unique index. ON UPDATE action - The action to do when a referenced column in the referenced table is being - updated to a new value. If the row is updated, but the referenced column - is not changed, no action is done. There are the following actions. + The action to do when a referenced column in the referenced + table is being updated to a new value. If the row is updated, + but the referenced column is not changed, no action is done. + There are the following actions. - CASCADE + NO ACTION - Update the value of the referencing column to the new value of the - referenced column. + Produce error if foreign key violated. This is the default. @@ -1052,31 +1037,32 @@ ERROR: Cannot insert a duplicate key into a unique index. RESTRICT - Disallow update of row being referenced. + Same as NO ACTION. - SET NULL + CASCADE - Set the referencing column values to NULL. + Update the value of the referencing column to the new value of the + referenced column. - SET DEFAULT + SET NULL - Set the referencing column values to their default value. + Set the referencing column values to NULL. - NO ACTION + SET DEFAULT - Do nothing. + Set the referencing column values to their default value. @@ -1089,8 +1075,10 @@ ERROR: Cannot insert a duplicate key into a unique index. [ NOT ] DEFERRABLE - Tells the trigger manager whether this constraint may be - deferred to the end of transaction. + This controls whether the constraint can be deferred to the end + of the transaction. If DEFERRABLE, SET CONSTRAINTS ALL DEFERRED + will cause the foreign key to be checked only at the end of the + transaction. NOT DEFERRABLE is the default. @@ -1101,22 +1089,20 @@ ERROR: Cannot insert a duplicate key into a unique index. checktime has two possible values which specify the default time to check the constraint. - DEFERRED - Check this constraint at the end of the transaction. + Check constraint only at the end of the transaction. - IMMEDIATE - Check this constraint after each statement. + Check constraint after each statement. This is the default. @@ -1167,16 +1153,15 @@ ERROR: name referential integrity Description - The REFERENCES column constraint specifies that a column of a - table must only contain values which match against values - in a referenced column of a referenced table. + The REFERENCES column constraint specifies that a + column of a table must only contain values which match against + values in a referenced column of a referenced table. - A value added to this column are matched against the - values of the referenced table and referenced column using - the given match type. - In addition, when the referenced column data is changed, - actions are run upon this column's matching data. + A value added to this column are matched against the values of the + referenced table and referenced column using the given match type. + In addition, when the referenced column data is changed, actions + are run upon this column's matching data. @@ -1188,12 +1173,11 @@ ERROR: name referential integrity Notes - Currently Postgres only supports - MATCH FULL and an unspecified match type. - In addition, the referenced columns are supposed to be - the columns of a UNIQUE constraint in the referenced table, - however Postgres does not - enforce this. + Currently Postgres only supports MATCH + FULL and an unspecified match type. In addition, the referenced + columns are supposed to be the columns of a UNIQUE constraint in + the referenced table, however Postgres + does not enforce this. @@ -1281,14 +1265,6 @@ ERROR: name referential integrity FOREIGN KEY - - - - Postgres now - supports FOREIGN KEY - integrity constraints - - @@ -1354,10 +1330,11 @@ ERROR: name referential integrity - The UNIQUE constraint specifies a rule that a group of one or - more distinct columns of a table may contain only unique values. - The behavior of the UNIQUE table constraint is the same as that for column - constraints, with the additional capability to span multiple columns. + The UNIQUE constraint specifies a rule that a group of one or more + distinct columns of a table may contain only unique values. The + behavior of the UNIQUE table constraint is the same as that for + column constraints, with the additional capability to span multiple + columns. See the section on the UNIQUE column constraint for more details. @@ -1428,8 +1405,8 @@ CREATE TABLE distributors ( ERROR: Cannot insert a duplicate key into a unique index. - This occurs at run-time if one tries to insert a duplicate value into - a column subject to a PRIMARY KEY constraint. + This occurs at run-time if one tries to insert a duplicate + value into a column subject to a PRIMARY KEY constraint. @@ -1475,14 +1452,13 @@ FOREIGN KEY ( column [, ...] ) REFE [ MATCH matchtype ] [ ON DELETE action ] [ ON UPDATE action ] -[ [ NOT ] DEFERRABLE ] +[ [ NOT ] DEFERRABLE ] [ INITIALLY checktime ] - The REFERENCES constraint specifies a rule that a column - value is checked against the values of another column. - REFERENCES can also be specified as part of - a FOREIGN KEY table constraint. + The REFERENCES constraint specifies a rule that a column value is + checked against the values of another column. REFERENCES can also be + specified as part of a FOREIGN KEY table constraint. @@ -1527,9 +1503,10 @@ FOREIGN KEY ( column [, ...] ) REFE MATCH matchtype - The type of comparison to do between the table data. There are three - types of matching, MATCH FULL, MATCH PARTIAL, and the unspecified match type - used if no match type is specified. + The type of comparison to do between the table data. There are + three types of matching, MATCH FULL, MATCH PARTIAL, and the + unspecified match type used if no match type is specified. + MATCH PARTIAL is not currently supported. @@ -1541,10 +1518,10 @@ FOREIGN KEY ( column [, ...] ) REFE deleted. There are the following actions. - CASCADE + NO ACTION - Delete any rows referencing the deleted row. + Produce error if foreign key violated. This is the default. @@ -1552,31 +1529,31 @@ FOREIGN KEY ( column [, ...] ) REFE RESTRICT - Disallow deletion of rows being referenced. + Same as NO ACTION. - SET NULL + CASCADE - Set the referencing column values to NULL. + Delete any rows referencing the deleted row. - SET DEFAULT + SET NULL - Set the referencing column values to their default value. + Set the referencing column values to NULL. - NO ACTION + SET DEFAULT - Do nothing. + Set the referencing column values to their default value. @@ -1588,16 +1565,16 @@ FOREIGN KEY ( column [, ...] ) REFE ON UPDATE action - The action to do when a referenced column in the referenced table is being - updated to a new value. If the row is updated, but the referenced column - is not changed, no action is done. There are the following actions. + The action to do when a referenced column in the referenced + table is being updated to a new value. If the row is updated, + but the referenced column is not changed, no action is done. + There are the following actions. - CASCADE + NO ACTION - Update the value of the referencing column to the new value of the - referenced column. + Produce error if foreign key violated. This is the default. @@ -1610,26 +1587,27 @@ FOREIGN KEY ( column [, ...] ) REFE - SET NULL + CASCADE - Set the referencing column values to NULL. + Update the value of the referencing column to the new value + of the referenced column. - SET DEFAULT + SET NULL - Set the referencing column values to their default value. + Set the referencing column values to NULL. - NO ACTION + SET DEFAULT - Do nothing. + Set the referencing column values to their default value. @@ -1641,8 +1619,10 @@ FOREIGN KEY ( column [, ...] ) REFE [ NOT ] DEFERRABLE - Tells the trigger manager whether this constraint may be - deferred to the end of transaction. + This controls whether the constraint can be deferred to the end + of the transaction. If DEFERRABLE, SET CONSTRAINTS ALL DEFERRED + will cause the foreign key to be checked only at the end of the + transaction. NOT DEFERRABLE is the default. @@ -1650,22 +1630,23 @@ FOREIGN KEY ( column [, ...] ) REFE INITIALLY checktime - checktime has two possible values - which specify the default time to check the constraint. + checktime has two + possible values which specify the default time to check the + constraint. - DEFERRED + IMMEDIATE - Check this constraint at the end of the transaction. + Check constraint after each statement. This is the default. - IMMEDIATE + DEFERRED - Check this constraint after each statement. + Check constraint only at the end of the transaction. @@ -1719,8 +1700,9 @@ ERROR: name referential integrity - The FOREIGN KEY table constraint is similar to that for column constraints, - with the additional capability of encompassing multiple columns. + The FOREIGN KEY table constraint is similar to that for column + constraints, with the additional capability of encompassing + multiple columns. Refer to the section on the FOREIGN KEY column constraint for more @@ -1886,10 +1868,10 @@ CREATE GLOBAL TEMPORARY TABLE table constraints. - The optional ON COMMIT clause of CREATE TEMPORARY TABLE - specifies whether or not the temporary table should be emptied of - rows whenever COMMIT is executed. If the ON COMMIT clause is - omitted, the default option, ON COMMIT DELETE ROWS, is assumed. + The optional ON COMMIT clause of CREATE TEMPORARY TABLE specifies + whether or not the temporary table should be emptied of rows + whenever COMMIT is executed. If the ON COMMIT clause is omitted, the + default option, ON COMMIT DELETE ROWS, is assumed. To create a temporary table: @@ -1936,10 +1918,10 @@ CREATE TEMPORARY TABLE actors ( NULL clause - The NULL "constraint" (actually a non-constraint) - 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. + The NULL "constraint" (actually a non-constraint) 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 @@ -2001,11 +1983,10 @@ the column. Not our problem... An assertion is a special type of integrity constraint and share - the same namespace as other constraints. - However, an assertion is not necessarily dependent on one - particular base table as constraints are, so SQL-92 provides the - CREATE ASSERTION statement as an alternate method for defining a - constraint: + the same namespace as other constraints. However, an assertion is + not necessarily dependent on one particular base table as + constraints are, so SQL-92 provides the CREATE ASSERTION statement + as an alternate method for defining a constraint: CREATE ASSERTION name CHECK ( condition ) @@ -2053,8 +2034,9 @@ CREATE ASSERTION name CHECK ( condition ) NOT DEFERRABLE - means that the Constraint must be checked for - violation of its rule after the execution of every SQL statement. + The constraint must be checked at the end of each statement. + SET CONSTRAINTS ALL DEFERRED will have no effect on this type + of constraint. @@ -2062,9 +2044,11 @@ CREATE ASSERTION name CHECK ( condition ) DEFERRABLE - means that checking of the Constraint may be deferred - until some later time, but no later than the end of the current - transaction. + This controls whether the constraint can be deferred to the end + of the transaction. If SET CONSTRAINTS ALL DEFERRED is used or + the constraint is set to INITIALLY DEFERRED, this will cause + the foreign key to be checked only at the end of the + transaction. @@ -2079,9 +2063,8 @@ CREATE ASSERTION name CHECK ( condition ) INITIALLY IMMEDIATE - means that, as of the start of the transaction, - the Constraint must be checked for violation of its rule after the - execution of every SQL statement. + Check constraint only at the end of the transaction. This + is the default @@ -2089,9 +2072,8 @@ CREATE ASSERTION name CHECK ( condition ) INITIALLY DEFERRED - means that, as of the start of the transaction, - checking of the Constraint may be deferred until some later time, - but no later than the end of the current transaction. + Check constraint after each statement. +