2 $PostgreSQL: pgsql/doc/src/sgml/ref/create_table.sgml,v 1.88 2004/12/13 18:05:10 petere Exp $
3 PostgreSQL documentation
6 <refentry id="SQL-CREATETABLE">
8 <refentrytitle id="sql-createtable-title">CREATE TABLE</refentrytitle>
9 <refmiscinfo>SQL - Language Statements</refmiscinfo>
13 <refname>CREATE TABLE</refname>
14 <refpurpose>define a new table</refpurpose>
17 <indexterm zone="sql-createtable">
18 <primary>CREATE TABLE</primary>
23 CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable class="PARAMETER">table_name</replaceable> (
24 { <replaceable class="PARAMETER">column_name</replaceable> <replaceable class="PARAMETER">data_type</replaceable> [ DEFAULT <replaceable>default_expr</> ] [ <replaceable class="PARAMETER">column_constraint</replaceable> [ ... ] ]
25 | <replaceable>table_constraint</replaceable>
26 | LIKE <replaceable>parent_table</replaceable> [ { INCLUDING | EXCLUDING } DEFAULTS ] } [, ... ]
28 [ INHERITS ( <replaceable>parent_table</replaceable> [, ... ] ) ]
29 [ WITH OIDS | WITHOUT OIDS ]
30 [ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ]
31 [ TABLESPACE <replaceable class="PARAMETER">tablespace</replaceable> ]
33 where <replaceable class="PARAMETER">column_constraint</replaceable> is:
35 [ CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> ]
38 UNIQUE [ USING INDEX TABLESPACE <replaceable class="PARAMETER">tablespace</replaceable> ] |
39 PRIMARY KEY [ USING INDEX TABLESPACE <replaceable class="PARAMETER">tablespace</replaceable> ] |
40 CHECK (<replaceable class="PARAMETER">expression</replaceable>) |
41 REFERENCES <replaceable class="PARAMETER">reftable</replaceable> [ ( <replaceable class="PARAMETER">refcolumn</replaceable> ) ] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ]
42 [ ON DELETE <replaceable class="parameter">action</replaceable> ] [ ON UPDATE <replaceable class="parameter">action</replaceable> ] }
43 [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
45 and <replaceable class="PARAMETER">table_constraint</replaceable> is:
47 [ CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> ]
48 { UNIQUE ( <replaceable class="PARAMETER">column_name</replaceable> [, ... ] ) [ USING INDEX TABLESPACE <replaceable class="PARAMETER">tablespace</replaceable> ] |
49 PRIMARY KEY ( <replaceable class="PARAMETER">column_name</replaceable> [, ... ] ) [ USING INDEX TABLESPACE <replaceable class="PARAMETER">tablespace</replaceable> ] |
50 CHECK ( <replaceable class="PARAMETER">expression</replaceable> ) |
51 FOREIGN KEY ( <replaceable class="PARAMETER">column_name</replaceable> [, ... ] ) REFERENCES <replaceable class="PARAMETER">reftable</replaceable> [ ( <replaceable class="PARAMETER">refcolumn</replaceable> [, ... ] ) ]
52 [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE <replaceable class="parameter">action</replaceable> ] [ ON UPDATE <replaceable class="parameter">action</replaceable> ] }
53 [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
58 <refsect1 id="SQL-CREATETABLE-description">
59 <title>Description</title>
62 <command>CREATE TABLE</command> will create a new, initially empty table
63 in the current database. The table will be owned by the user issuing the
68 If a schema name is given (for example, <literal>CREATE TABLE
69 myschema.mytable ...</>) then the table is created in the
70 specified schema. Otherwise it is created in the current schema.
71 Temporary tables exist in a special schema, so a schema name may not be
72 given when creating a temporary table.
73 The table name must be distinct from the name of any other table,
74 sequence, index, or view in the same schema.
78 <command>CREATE TABLE</command> also automatically creates a data
79 type that represents the composite type corresponding
80 to one row of the table. Therefore, tables cannot have the same
81 name as any existing data type in the same schema.
85 A table cannot have more than 1600 columns. (In practice, the
86 effective limit is lower because of tuple-length constraints).
90 The optional constraint clauses specify constraints (or tests) that
91 new or updated rows must satisfy for an insert or update operation
92 to succeed. A constraint is an SQL object that helps define the
93 set of valid values in the table in various ways.
97 There are two ways to define constraints: table constraints and
98 column constraints. A column constraint is defined as part of a
99 column definition. A table constraint definition is not tied to a
100 particular column, and it can encompass more than one column.
101 Every column constraint can also be written as a table constraint;
102 a column constraint is only a notational convenience if the
103 constraint only affects one column.
108 <title>Parameters</title>
113 <term><literal>TEMPORARY</> or <literal>TEMP</></term>
116 If specified, the table is created as a temporary table.
117 Temporary tables are automatically dropped at the end of a
118 session, or optionally at the end of the current transaction
119 (see <literal>ON COMMIT</literal> below). Existing permanent
120 tables with the same name are not visible to the current session
121 while the temporary table exists, unless they are referenced
122 with schema-qualified names. Any indexes created on a temporary
123 table are automatically temporary as well.
127 Optionally, <literal>GLOBAL</literal> or <literal>LOCAL</literal>
128 can be written before <literal>TEMPORARY</> or <literal>TEMP</>.
129 This makes no difference in <productname>PostgreSQL</>, but see
130 <xref linkend="sql-createtable-compatibility"
131 endterm="sql-createtable-compatibility-title">.
137 <term><replaceable class="PARAMETER">table_name</replaceable></term>
140 The name (optionally schema-qualified) of the table to be created.
146 <term><replaceable class="PARAMETER">column_name</replaceable></term>
149 The name of a column to be created in the new table.
155 <term><replaceable class="PARAMETER">data_type</replaceable></term>
158 The data type of the column. This may include array
159 specifiers. For more information on the data types included with
160 <productname>PostgreSQL</productname>, refer to <xref
167 <term><literal>DEFAULT
168 <replaceable>default_expr</replaceable></literal></term>
171 The <literal>DEFAULT</> clause assigns a default data value for
172 the column whose column definition it appears within. The value
173 is any variable-free expression (subqueries and cross-references
174 to other columns in the current table are not allowed). The
175 data type of the default expression must match the data type of the
180 The default expression will be used in any insert operation that
181 does not specify a value for the column. If there is no default
182 for a column, then the default is null.
188 <term><literal>LIKE <replaceable>parent_table</replaceable> [ { INCLUDING | EXCLUDING } DEFAULTS ]</literal></term>
191 The <literal>LIKE</literal> clause specifies a table from which
192 the new table automatically copies all column names, their data types,
193 and their not-null constraints.
196 Unlike <literal>INHERITS</literal>, the new table and original table
197 are completely decoupled after creation is complete. Changes to the
198 original table will not be applied to the new table, and it is not
199 possible to include data of the new table in scans of the original
203 Default expressions for the copied column definitions will only be
204 included if <literal>INCLUDING DEFAULTS</literal> is specified. The
205 default is to exclude default expressions.
211 <term><literal>INHERITS ( <replaceable>parent_table</replaceable> [, ... ] )</literal></term>
214 The optional <literal>INHERITS</> clause specifies a list of
215 tables from which the new table automatically inherits all
220 Use of <literal>INHERITS</> creates a persistent relationship
221 between the new child table and its parent table(s). Schema
222 modifications to the parent(s) normally propagate to children
223 as well, and by default the data of the child table is included in
224 scans of the parent(s).
228 If the same column name exists in more than one parent
229 table, an error is reported unless the data types of the columns
230 match in each of the parent tables. If there is no conflict,
231 then the duplicate columns are merged to form a single column in
232 the new table. If the column name list of the new table
233 contains a column name that is also inherited, the data type must
234 likewise match the inherited column(s), and the column
235 definitions are merged into one. However, inherited and new
236 column declarations of the same name need not specify identical
237 constraints: all constraints provided from any declaration are
238 merged together and all are applied to the new table. If the
239 new table explicitly specifies a default value for the column,
240 this default overrides any defaults from inherited declarations
241 of the column. Otherwise, any parents that specify default
242 values for the column must all specify the same default, or an
243 error will be reported.
247 <productname>PostgreSQL</> automatically allows the
248 created table to inherit
249 functions on tables above it in the inheritance hierarchy; that
250 is, if we create table <literal>foo</literal> inheriting from
251 <literal>bar</literal>, then functions that accept the tuple
252 type <literal>bar</literal> can also be applied to instances of
253 <literal>foo</literal>. (Currently, this works reliably for
254 functions on the first or only parent table, but not so well for
255 functions on additional parents.)
262 <term><literal>WITH OIDS</></term>
263 <term><literal>WITHOUT OIDS</></term>
266 This optional clause specifies whether rows of the new table
267 should have OIDs (object identifiers) assigned to them. If
268 neither <literal>WITH OIDS</literal> nor <literal>WITHOUT
269 OIDS</literal> is specified, the default value depends upon the
270 <xref linkend="guc-default-with-oids"> configuration parameter. (If
271 the new table inherits from any tables that have OIDs, then
272 <literal>WITH OIDS</> is forced even if the command says
273 <literal>WITHOUT OIDS</>.)
277 If <literal>WITHOUT OIDS</literal> is specified or implied, this
278 means that the generation of OIDs for this table will be
279 supressed. This is generally considered worthwhile, since it
280 will reduce OID consumption and thereby postpone the wraparound
281 of the 32-bit OID counter. Once the counter wraps around, OIDs
282 can no longer be assumed to be unique, which makes them
283 considerably less useful. In addition, excluding OIDs from a
284 table reduces the space required on disk to storage the table by
285 4 bytes per row, leading to increased performance.
289 To remove OIDs from a table after it has been created, use <xref
290 linkend="sql-altertable" endterm="sql-altertable-title">.
296 <term><literal>CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable></literal></term>
299 An optional name for a column or table constraint. If not specified,
300 the system generates a name.
306 <term><literal>NOT NULL</></term>
309 The column is not allowed to contain null values.
315 <term><literal>NULL</></term>
318 The column is allowed to contain null values. This is the default.
322 This clause is only available for compatibility with
323 non-standard SQL databases. Its use is discouraged in new
330 <term><literal>UNIQUE</> (column constraint)</term>
331 <term><literal>UNIQUE ( <replaceable class="PARAMETER">column_name</replaceable> [, ... ] )</> (table constraint)</term>
335 The <literal>UNIQUE</literal> constraint specifies that a
336 group of one or more distinct columns of a table may contain
337 only unique values. The behavior of the unique table constraint
338 is the same as that for column constraints, with the additional
339 capability to span multiple columns.
343 For the purpose of a unique constraint, null values are not
348 Each unique table constraint must name a set of columns that is
349 different from the set of columns named by any other unique or
350 primary key constraint defined for the table. (Otherwise it
351 would just be the same constraint listed twice.)
357 <term><literal>PRIMARY KEY</> (column constraint)</term>
358 <term><literal>PRIMARY KEY ( <replaceable class="PARAMETER">column_name</replaceable> [, ... ] )</> (table constraint)</term>
361 The primary key constraint specifies that a column or columns of a table
362 may contain only unique (non-duplicate), nonnull values.
363 Technically, <literal>PRIMARY KEY</literal> is merely a
364 combination of <literal>UNIQUE</> and <literal>NOT NULL</>, but
365 identifying a set of columns as primary key also provides
366 metadata about the design of the schema, as a primary key
367 implies that other tables
368 may rely on this set of columns as a unique identifier for rows.
372 Only one primary key can be specified for a table, whether as a
373 column constraint or a table constraint.
377 The primary key constraint should name a set of columns that is
378 different from other sets of columns named by any unique
379 constraint defined for the same table.
385 <term><literal>CHECK (<replaceable class="PARAMETER">expression</replaceable>)</literal></term>
388 The <literal>CHECK</> clause specifies an expression producing a
389 Boolean result which new or updated rows must satisfy for an
390 insert or update operation to succeed. Expressions evaluating
391 to TRUE or UNKNOWN succeed. Should any row of an insert or
392 update operation produce a FALSE result an error exception is
393 raised and the insert or update does not alter the database. A
394 check constraint specified as a column constraint should
395 reference that column's value only, while an expression
396 appearing in a table constraint may reference multiple columns.
400 Currently, <literal>CHECK</literal> expressions cannot contain
401 subqueries nor refer to variables other than columns of the
409 <term><literal>REFERENCES <replaceable class="parameter">reftable</replaceable> [ ( <replaceable class="parameter">refcolumn</replaceable> ) ] [ MATCH <replaceable class="parameter">matchtype</replaceable> ] [ ON DELETE <replaceable class="parameter">action</replaceable> ] [ ON UPDATE <replaceable class="parameter">action</replaceable> ]</literal> (column constraint)</term>
411 <term><literal>FOREIGN KEY ( <replaceable class="parameter">column</replaceable> [, ... ] )
412 REFERENCES <replaceable class="parameter">reftable</replaceable> [ ( <replaceable class="parameter">refcolumn</replaceable> [, ... ] ) ]
413 [ MATCH <replaceable class="parameter">matchtype</replaceable> ]
414 [ ON DELETE <replaceable class="parameter">action</replaceable> ]
415 [ ON UPDATE <replaceable class="parameter">action</replaceable> ]</literal>
416 (table constraint)</term>
420 These clauses specify a foreign key constraint, which requires
421 that a group of one or more columns of the new table must only
422 contain values that match values in the referenced
423 column(s) of some row of the referenced table. If <replaceable
424 class="parameter">refcolumn</replaceable> is omitted, the
425 primary key of the <replaceable
426 class="parameter">reftable</replaceable> is used. The
427 referenced columns must be the columns of a unique or primary
428 key constraint in the referenced table.
432 A value inserted into the referencing column(s) is matched against the
433 values of the referenced table and referenced columns using the
434 given match type. There are three match types: <literal>MATCH
435 FULL</>, <literal>MATCH PARTIAL</>, and <literal>MATCH
436 SIMPLE</literal>, which is also the default. <literal>MATCH
437 FULL</> will not allow one column of a multicolumn foreign key
438 to be null unless all foreign key columns are null.
439 <literal>MATCH SIMPLE</literal> allows some foreign key columns
440 to be null while other parts of the foreign key are not
441 null. <literal>MATCH PARTIAL</> is not yet implemented.
445 In addition, when the data in the referenced columns is changed,
446 certain actions are performed on the data in this table's
447 columns. The <literal>ON DELETE</literal> clause specifies the
448 action to perform when a referenced row in the referenced table is
449 being deleted. Likewise, the <literal>ON UPDATE</literal>
450 clause specifies the action to perform when a referenced column
451 in the referenced table is being updated to a new value. If the
452 row is updated, but the referenced column is not actually
453 changed, no action is done. Referential actions apart from the
454 check of <literal>NO ACTION</literal> can not be deferred even if
455 the constraint is deferrable. There are the following possible
456 actions for each clause:
460 <term><literal>NO ACTION</literal></term>
463 Produce an error indicating that the deletion or update
464 would create a foreign key constraint violation.
465 If the constraint is deferred, this
466 error will be produced at constraint check time if there still
467 exist any referencing rows. This is the default action.
473 <term><literal>RESTRICT</literal></term>
476 Produce an error indicating that the deletion or update
477 would create a foreign key constraint violation.
478 This is the same as <literal>NO ACTION</literal> except that
479 the check is not deferrable.
485 <term><literal>CASCADE</literal></term>
488 Delete any rows referencing the deleted row, or update the
489 value of the referencing column to the new value of the
490 referenced column, respectively.
496 <term><literal>SET NULL</literal></term>
499 Set the referencing column(s) to null.
505 <term><literal>SET DEFAULT</literal></term>
508 Set the referencing column(s) to their default values.
516 If the referenced column(s) are changed frequently, it may be wise to
517 add an index to the foreign key column so that referential actions
518 associated with the foreign key column can be performed more
525 <term><literal>DEFERRABLE</literal></term>
526 <term><literal>NOT DEFERRABLE</literal></term>
529 This controls whether the constraint can be deferred. A
530 constraint that is not deferrable will be checked immediately
531 after every command. Checking of constraints that are
532 deferrable may be postponed until the end of the transaction
533 (using the <xref linkend="sql-set-constraints" endterm="sql-set-constraints-title"> command).
534 <literal>NOT DEFERRABLE</literal> is the default. Only foreign
535 key constraints currently accept this clause. All other
536 constraint types are not deferrable.
542 <term><literal>INITIALLY IMMEDIATE</literal></term>
543 <term><literal>INITIALLY DEFERRED</literal></term>
546 If a constraint is deferrable, this clause specifies the default
547 time to check the constraint. If the constraint is
548 <literal>INITIALLY IMMEDIATE</literal>, it is checked after each
549 statement. This is the default. If the constraint is
550 <literal>INITIALLY DEFERRED</literal>, it is checked only at the
551 end of the transaction. The constraint check time can be
552 altered with the <xref linkend="sql-set-constraints" endterm="sql-set-constraints-title"> command.
558 <term><literal>ON COMMIT</literal></term>
561 The behavior of temporary tables at the end of a transaction
562 block can be controlled using <literal>ON COMMIT</literal>.
563 The three options are:
567 <term><literal>PRESERVE ROWS</literal></term>
570 No special action is taken at the ends of transactions.
571 This is the default behavior.
577 <term><literal>DELETE ROWS</literal></term>
580 All rows in the temporary table will be deleted at the
581 end of each transaction block. Essentially, an automatic
582 <xref linkend="sql-truncate"> is done at each commit.
588 <term><literal>DROP</literal></term>
591 The temporary table will be dropped at the end of the current
602 <term><literal>TABLESPACE <replaceable class="PARAMETER">tablespace</replaceable></literal></term>
605 The <replaceable class="PARAMETER">tablespace</replaceable> is the name
606 of the tablespace in which the new table is to be created.
608 <xref linkend="guc-default-tablespace"> is used, or the database's
609 default tablespace if <varname>default_tablespace</> is an empty
616 <term><literal>USING INDEX TABLESPACE <replaceable class="PARAMETER">tablespace</replaceable></literal></term>
619 This clause allows selection of the tablespace in which the index
620 associated with a <literal>UNIQUE</literal> or <literal>PRIMARY
621 KEY</literal> constraint will be created.
623 <xref linkend="guc-default-tablespace"> is used, or the database's
624 default tablespace if <varname>default_tablespace</> is an empty
633 <refsect1 id="SQL-CREATETABLE-notes">
639 Using OIDs in new applications is not recommended: where
640 possible, using a <literal>SERIAL</literal> or other sequence
641 generator as the table's primary key is preferred. However, if
642 your application does make use of OIDs to identify specific rows
643 rows of a table, it is recommended to create a unique constraint
644 on the <structfield>oid</> column of that table, to ensure that
645 OIDs in the table will indeed uniquely identify rows even after
646 counter wraparound. Avoid assuming that OIDs are unique across
647 tables; if you need a database-wide unique identifier, use the
648 combination of <structfield>tableoid</> and row OID for the
654 The use of <literal>WITHOUT OIDS</literal> is not recommended
655 for tables with no primary key, since without either an OID or a
656 unique data key, it is difficult to identify specific rows.
663 <productname>PostgreSQL</productname> automatically creates an
664 index for each unique constraint and primary key constraint to
665 enforce the uniqueness. Thus, it is not necessary to create an
666 explicit index for primary key columns. (See <xref
667 linkend="sql-createindex" endterm="sql-createindex-title"> for more information.)
673 Unique constraints and primary keys are not inherited in the
674 current implementation. This makes the combination of
675 inheritance and unique constraints rather dysfunctional.
682 <refsect1 id="SQL-CREATETABLE-examples">
683 <title>Examples</title>
686 Create table <structname>films</> and table
687 <structname>distributors</>:
691 code char(5) CONSTRAINT firstkey PRIMARY KEY,
692 title varchar(40) NOT NULL,
693 did integer NOT NULL,
696 len interval hour to minute
701 CREATE TABLE distributors (
702 did integer PRIMARY KEY DEFAULT nextval('serial'),
703 name varchar(40) NOT NULL CHECK (name <> '')
709 Create a table with a 2-dimensional array:
719 Define a unique table constraint for the table
720 <literal>films</literal>. Unique table constraints can be defined
721 on one or more columns of the table.
730 len interval hour to minute,
731 CONSTRAINT production UNIQUE(date_prod)
737 Define a check column constraint:
740 CREATE TABLE distributors (
741 did integer CHECK (did > 100),
748 Define a check table constraint:
751 CREATE TABLE distributors (
754 CONSTRAINT con1 CHECK (did > 100 AND name <> '')
760 Define a primary key table constraint for the table
761 <structname>films</>. Primary key table constraints can be defined
762 on one or more columns of the table.
771 len interval hour to minute,
772 CONSTRAINT code_title PRIMARY KEY(code,title)
778 Define a primary key constraint for table
779 <structname>distributors</>. The following two examples are
780 equivalent, the first using the table constraint syntax, the second
781 the column constraint notation.
784 CREATE TABLE distributors (
792 CREATE TABLE distributors (
793 did integer PRIMARY KEY,
800 This assigns a literal constant default value for the column
801 <literal>name</literal>, arranges for the default value of column
802 <literal>did</literal> to be generated by selecting the next value
803 of a sequence object, and makes the default value of
804 <literal>modtime</literal> be the time at which the row is
808 CREATE TABLE distributors (
809 name varchar(40) DEFAULT 'Luso Films',
810 did integer DEFAULT nextval('distributors_serial'),
811 modtime timestamp DEFAULT current_timestamp
817 Define two <literal>NOT NULL</> column constraints on the table
818 <classname>distributors</classname>, one of which is explicitly
822 CREATE TABLE distributors (
823 did integer CONSTRAINT no_null NOT NULL,
824 name varchar(40) NOT NULL
830 Define a unique constraint for the <literal>name</literal> column:
833 CREATE TABLE distributors (
835 name varchar(40) UNIQUE
839 The above is equivalent to the following specified as a table constraint:
842 CREATE TABLE distributors (
851 Create table <structname>cinemas</> in tablespace <structname>diskvol1</>:
854 CREATE TABLE cinemas (
858 ) TABLESPACE diskvol1;
864 <refsect1 id="SQL-CREATETABLE-compatibility">
865 <title id="SQL-CREATETABLE-compatibility-title">Compatibility</title>
868 The <command>CREATE TABLE</command> command conforms to SQL-92 and
869 to a subset of SQL:1999, with exceptions listed below.
873 <title>Temporary Tables</title>
876 Although the syntax of <literal>CREATE TEMPORARY TABLE</literal>
877 resembles that of the SQL standard, the effect is not the same. In the
879 temporary tables are defined just once and automatically exist (starting
880 with empty contents) in every session that needs them.
881 <productname>PostgreSQL</productname> instead
882 requires each session to issue its own <literal>CREATE TEMPORARY
883 TABLE</literal> command for each temporary table to be used. This allows
884 different sessions to use the same temporary table name for different
885 purposes, whereas the standard's approach constrains all instances of a
886 given temporary table name to have the same table structure.
890 The standard's definition of the behavior of temporary tables is
891 widely ignored. <productname>PostgreSQL</productname>'s behavior
892 on this point is similar to that of several other SQL databases.
896 The standard's distinction between global and local temporary tables
897 is not in <productname>PostgreSQL</productname>, since that distinction
898 depends on the concept of modules, which
899 <productname>PostgreSQL</productname> does not have.
900 For compatibility's sake, <productname>PostgreSQL</productname> will
901 accept the <literal>GLOBAL</literal> and <literal>LOCAL</literal> keywords
902 in a temporary table declaration, but they have no effect.
906 The <literal>ON COMMIT</literal> clause for temporary tables
907 also resembles the SQL standard, but has some differences.
908 If the <literal>ON COMMIT</> clause is omitted, SQL specifies that the
909 default behavior is <literal>ON COMMIT DELETE ROWS</>. However, the
910 default behavior in <productname>PostgreSQL</productname> is
911 <literal>ON COMMIT PRESERVE ROWS</literal>. The <literal>ON COMMIT
912 DROP</literal> option does not exist in SQL.
917 <title>Column Check Constraints</title>
920 The SQL standard says that <literal>CHECK</> column constraints
921 may only refer to the column they apply to; only <literal>CHECK</>
922 table constraints may refer to multiple columns.
923 <productname>PostgreSQL</productname> does not enforce this
924 restriction; it treats column and table check constraints alike.
929 <title><literal>NULL</literal> <quote>Constraint</quote></title>
932 The <literal>NULL</> <quote>constraint</quote> (actually a
933 non-constraint) is a <productname>PostgreSQL</productname>
934 extension to the SQL standard that is included for compatibility with some
935 other database systems (and for symmetry with the <literal>NOT
936 NULL</literal> constraint). Since it is the default for any
937 column, its presence is simply noise.
942 <title>Inheritance</title>
945 Multiple inheritance via the <literal>INHERITS</literal> clause is
946 a <productname>PostgreSQL</productname> language extension.
947 SQL:1999 (but not SQL-92) defines single inheritance using a
948 different syntax and different semantics. SQL:1999-style
949 inheritance is not yet supported by
950 <productname>PostgreSQL</productname>.
955 <title>Object IDs</title>
958 The <productname>PostgreSQL</productname> concept of OIDs is not
964 <title>Zero-column tables</title>
967 <productname>PostgreSQL</productname> allows a table of no columns
968 to be created (for example, <literal>CREATE TABLE foo();</>). This
969 is an extension from the SQL standard, which does not allow zero-column
970 tables. Zero-column tables are not in themselves very useful, but
971 disallowing them creates odd special cases for <command>ALTER TABLE
972 DROP COLUMN</>, so it seems cleaner to ignore this spec restriction.
977 <title>Tablespaces</title>
980 The <productname>PostgreSQL</productname> concept of tablespaces is not
981 part of the standard. Hence, the clauses <literal>TABLESPACE</literal>
982 and <literal>USING INDEX TABLESPACE</literal> are extensions.
989 <title>See Also</title>
991 <simplelist type="inline">
992 <member><xref linkend="sql-altertable" endterm="sql-altertable-title"></member>
993 <member><xref linkend="sql-droptable" endterm="sql-droptable-title"></member>
994 <member><xref linkend="sql-createtablespace" endterm="sql-createtablespace-title"></member>
999 <!-- Keep this comment at the end of the file
1004 sgml-minimize-attributes:nil
1005 sgml-always-quote-attributes:t
1008 sgml-parent-document:nil
1009 sgml-default-dtd-file:"../reference.ced"
1010 sgml-exposed-tags:nil
1011 sgml-local-catalogs:"/usr/lib/sgml/catalog"
1012 sgml-local-ecat-files:nil