1
1
<!--
2
- $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table.sgml,v 1.41 2001/02/04 12:18:08 petere Exp $
2
+ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table.sgml,v 1.42 2001/05/03 17:50:55 tgl Exp $
3
3
Postgres documentation
4
4
-->
5
5
@@ -26,7 +26,7 @@ Postgres documentation
26
26
CREATE [ TEMPORARY | TEMP ] TABLE <replaceable class="PARAMETER">table_name</replaceable> (
27
27
{ <replaceable class="PARAMETER">column_name</replaceable> <replaceable class="PARAMETER">type</replaceable> [ <replaceable class="PARAMETER">column_constraint</replaceable> [ ... ] ]
28
28
| <replaceable>table_constraint</replaceable> } [, ... ]
29
- ) [ INHERITS ( <replaceable>inherited_table </replaceable> [, ... ] ) ]
29
+ ) [ INHERITS ( <replaceable>parent_table </replaceable> [, ... ] ) ]
30
30
31
31
where <replaceable class="PARAMETER">column_constraint</replaceable> can be:
32
32
[ CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> ]
@@ -99,17 +99,11 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> can be:
99
99
</varlistentry>
100
100
101
101
<varlistentry>
102
- <term><replaceable class="PARAMETER">inherited_table </replaceable></term>
102
+ <term><replaceable class="PARAMETER">parent_table </replaceable></term>
103
103
<listitem>
104
104
<para>
105
105
The optional INHERITS clause specifies a list of table
106
106
names from which this table automatically inherits all fields.
107
- If any inherited field name appears more than once,
108
- <productname>Postgres</productname>
109
- reports an error.
110
- <productname>Postgres</productname> automatically allows the created
111
- table to inherit functions on tables above it in the inheritance
112
- hierarchy.
113
107
</para>
114
108
</listitem>
115
109
</varlistentry>
@@ -258,20 +252,54 @@ ERROR: Relation '<replaceable class="parameter">table</replaceable>' already ex
258
252
existing datatype.
259
253
</para>
260
254
255
+ <para>
256
+ A table can have no more than 1600 columns (in practice, the
257
+ effective limit is lower because of tuple-length constraints).
258
+ A table cannot have the same name as a system catalog table.
259
+ </para>
260
+ </refsect1>
261
+
262
+ <refsect1 id="R1-SQL-INHERITSCLAUSE-1">
263
+ <title id="R1-SQL-INHERITSCLAUSE-1-TITLE">
264
+ INHERITS Clause
265
+ </title>
266
+ <para>
267
+ <synopsis>
268
+ INHERITS ( <replaceable class="PARAMETER">parent_table</replaceable> [, ... ] )
269
+ </synopsis>
270
+ </para>
271
+
261
272
<para>
262
273
The optional INHERITS
263
- clause specifies a collection of table names from which this table
264
- automatically inherits all fields. If any inherited field name
265
- appears more than once, Postgres reports an error. Postgres automatically
266
- allows the created table to inherit functions on tables above it in
267
- the inheritance hierarchy. Inheritance of functions is done according
268
- to the conventions of the Common Lisp Object System (CLOS).
274
+ clause specifies a list of table names from which the new table
275
+ automatically inherits all fields. If the same field name appears in
276
+ more than one parent table, Postgres reports an error unless the field
277
+ definitions match in each of the parent tables. If there is no
278
+ definition conflict, then the duplicate fields are merged to form a single
279
+ field of the new table. If the new table's own field list contains a
280
+ field name that is also inherited, this declaration must likewise match
281
+ the inherited field(s), and the field definitions are merged into one.
269
282
</para>
270
283
271
284
<para>
272
- A table can have no more than 1600 columns (in practice, the
273
- effective limit is lower because of tuple-length constraints).
274
- A table cannot have the same name as a system catalog table.
285
+ Inherited and new field declarations of the same name must specify exactly
286
+ the same data type to avoid an error. They need not specify identical
287
+ constraints --- all constraints provided from any declaration are merged
288
+ together and all are applied to the new table. If the new table explicitly
289
+ specifies a default value for the field, this default overrides any
290
+ defaults from inherited declarations of the field. Otherwise, any parents
291
+ that specify default values for the field must all specify the same
292
+ default, or an error will be reported.
293
+ </para>
294
+
295
+ <para>
296
+ Postgres automatically allows the created table to inherit functions on
297
+ tables above it in the inheritance hierarchy; that is, if we create table
298
+ <literal>foo</literal> inheriting from <literal>bar</literal>, then
299
+ functions that accept the tuple type <literal>bar</literal> can also be
300
+ applied to instances of <literal>foo</literal>. (Currently, this works
301
+ reliably for functions on the first or only parent table, but not so well
302
+ for functions on additional parents.)
275
303
</para>
276
304
</refsect1>
277
305
0 commit comments