11<!--
2- $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.98 2002/08/13 20:40:43 momjian Exp $
2+ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.99 2002/08/19 19:33:33 tgl Exp $
33-->
44
55 <chapter id="datatype">
@@ -665,14 +665,17 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (
665665<programlisting>
666666CREATE SEQUENCE <replaceable class="parameter">tablename</replaceable>_<replaceable class="parameter">colname</replaceable>_seq;
667667CREATE TABLE <replaceable class="parameter">tablename</replaceable> (
668- <replaceable class="parameter">colname</replaceable> integer DEFAULT nextval('<replaceable class="parameter">tablename</replaceable>_<replaceable class="parameter">colname</replaceable>_seq')UNIQUE NOT NULL
668+ <replaceable class="parameter">colname</replaceable> integer DEFAULT nextval('<replaceable class="parameter">tablename</replaceable>_<replaceable class="parameter">colname</replaceable>_seq') NOT NULL
669669);
670670</programlisting>
671671
672672 Thus, we have created an integer column and arranged for its default
673- values to be assigned from a sequence generator. UNIQUE and NOT NULL
674- constraints are applied to ensure that explicitly-inserted values
675- will never be duplicates, either.
673+ values to be assigned from a sequence generator. A <literal>NOT NULL</>
674+ constraint is applied to ensure that a NULL value cannot be explicitly
675+ inserted, either. In most cases you would also want to attach a
676+ <literal>UNIQUE</> or <literal>PRIMARY KEY</> constraint to prevent
677+ duplicate values from being inserted by accident, but this is
678+ not automatic.
676679 </para>
677680
678681 <para>
@@ -685,20 +688,23 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (
685688 </para>
686689
687690 <para>
688- Implicit sequences supporting the <type>serial</type> types are
689- not automatically dropped when a table containing a serial type
690- is dropped. So, the following commands executed in order will likely fail:
691-
692- <programlisting>
693- CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceable class="parameter">colname</replaceable> SERIAL);
694- DROP TABLE <replaceable class="parameter">tablename</replaceable>;
695- CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceable class="parameter">colname</replaceable> SERIAL);
696- </programlisting>
697-
698- The sequence will remain in the database until explicitly dropped using
699- <command>DROP SEQUENCE</command>. (This annoyance will probably be
700- fixed in some future release.)
691+ The sequence created by a <type>serial</type> type is automatically
692+ dropped when
693+ the owning column is dropped, and cannot be dropped otherwise.
694+ (This was not true in <productname>PostgreSQL</productname> releases
695+ before 7.3. Note that this automatic drop linkage will not occur for a
696+ sequence created by reloading a dump from a pre-7.3 database; the dump
697+ file does not contain the information needed to establish the dependency
698+ link.)
701699 </para>
700+
701+ <note><para>
702+ Prior to <productname>PostgreSQL</productname> 7.3, <type>serial</type>
703+ implied <literal>UNIQUE</literal>. This is no longer automatic. If
704+ you wish a serial column to be <literal>UNIQUE</literal> or a
705+ <literal>PRIMARY KEY</literal> it must now be specified, same as with
706+ any other datatype.
707+ </para></note>
702708 </sect2>
703709 </sect1>
704710