diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index 8a7796c5751..fb5e2b2a550 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -1,5 +1,5 @@ @@ -26,7 +26,7 @@ Postgres documentation CREATE [ TEMPORARY | TEMP ] TABLE table_name ( { column_name type [ column_constraint [ ... ] ] | table_constraint } [, ... ] - ) [ INHERITS ( inherited_table [, ... ] ) ] + ) [ INHERITS ( parent_table [, ... ] ) ] where column_constraint can be: [ CONSTRAINT constraint_name ] @@ -99,17 +99,11 @@ and table_constraint can be: - inherited_table + parent_table The optional INHERITS clause specifies a list of table names from which this table automatically inherits all fields. - If any inherited field name appears more than once, - Postgres - reports an error. - Postgres automatically allows the created - table to inherit functions on tables above it in the inheritance - hierarchy. @@ -258,16 +252,6 @@ ERROR: Relation 'table' already ex existing datatype. - - The optional INHERITS - clause specifies a collection of table names from which this table - automatically inherits all fields. If any inherited field name - appears more than once, Postgres reports an error. Postgres automatically - allows the created table to inherit functions on tables above it in - the inheritance hierarchy. Inheritance of functions is done according - to the conventions of the Common Lisp Object System (CLOS). - - A table can have no more than 1600 columns (in practice, the effective limit is lower because of tuple-length constraints). @@ -275,6 +259,50 @@ ERROR: Relation 'table' already ex + + + INHERITS Clause + + + +INHERITS ( parent_table [, ... ] ) + + + + + The optional INHERITS + clause specifies a list of table names from which the new table + automatically inherits all fields. If the same field name appears in + more than one parent table, Postgres reports an error unless the field + definitions match in each of the parent tables. If there is no + definition conflict, then the duplicate fields are merged to form a single + field of the new table. If the new table's own field list contains a + field name that is also inherited, this declaration must likewise match + the inherited field(s), and the field definitions are merged into one. + + + + Inherited and new field declarations of the same name must specify exactly + the same data type to avoid an error. They need not specify identical + constraints --- all constraints provided from any declaration are merged + together and all are applied to the new table. If the new table explicitly + specifies a default value for the field, this default overrides any + defaults from inherited declarations of the field. Otherwise, any parents + that specify default values for the field must all specify the same + default, or an error will be reported. + + + + Postgres automatically allows the created table to inherit functions on + tables above it in the inheritance hierarchy; that is, if we create table + foo inheriting from bar, then + functions that accept the tuple type bar can also be + applied to instances of foo. (Currently, this works + reliably for functions on the first or only parent table, but not so well + for functions on additional parents.) + + + DEFAULT Clause