db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chaa...@apache.org
Subject svn commit: r643094 - in /db/derby/docs/trunk/src/ref: rrefsqlj13590.dita rrefsqlj81859.dita
Date Mon, 31 Mar 2008 18:40:46 GMT
Author: chaase3
Date: Mon Mar 31 11:40:41 2008
New Revision: 643094

URL: http://svn.apache.org/viewvc?rev=643094&view=rev
Log:
DERBY-3474: Update unique constraint sections of reference manual

Modified the topics "CONSTRAINT clause" and "ALTER TABLE statement".

Modified:
    db/derby/docs/trunk/src/ref/rrefsqlj13590.dita
    db/derby/docs/trunk/src/ref/rrefsqlj81859.dita

Modified: db/derby/docs/trunk/src/ref/rrefsqlj13590.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/ref/rrefsqlj13590.dita?rev=643094&r1=643093&r2=643094&view=diff
==============================================================================
--- db/derby/docs/trunk/src/ref/rrefsqlj13590.dita (original)
+++ db/derby/docs/trunk/src/ref/rrefsqlj13590.dita Mon Mar 31 11:40:41 2008
@@ -53,8 +53,7 @@
 the primary key contain null values, an error will be generated and the primary
 key will not be added. See <xref href="rrefsqlj81859.dita#rrefsqlj81859"></xref>
for
 more information.</note></li>
-<li>UNIQUE   <p>Specifies that values in the column must be unique. NULL values
-are not allowed.</p></li>
+<li>UNIQUE   <p>Specifies that values in the column must be unique.</p></li>
 <li>FOREIGN KEY   <p>Specifies that the values in the column must correspond
 to values in a referenced primary key or unique key column or that they are
 NULL.</p></li>
@@ -64,8 +63,7 @@
 <li>PRIMARY KEY<indexterm>Primary keys<indexterm>creating</indexterm><indexterm>adding</indexterm></indexterm>
<p>Specifies
 the column or columns that uniquely identify a row in the table. NULL values
 are not allowed.</p></li>
-<li>UNIQUE   <p>Specifies that values in the columns must be unique. The identified
-columns must be defined as NOT NULL.</p></li>
+<li>UNIQUE   <p>Specifies that values in the columns must be unique.</p></li>
 <li>FOREIGN KEY   <p>Specifies that the values in the columns must correspond
 to values in referenced primary key or unique columns or that they are NULL.</p> <note>If
 the foreign key consists of multiple columns, and <i>any</i> column is NULL,
@@ -79,8 +77,8 @@
 CHECK, or FOREIGN KEY constraint definition. Column-level constraints (except
 for check constraints) refer to only one column.</p></section>
 <refsyn><title>Syntax</title> </refsyn>
-<section><title>Primary key and unique constraints</title> <p><indexterm>Primary
-key constraints</indexterm><indexterm>Unique constraints</indexterm>A primary
+<section><title>Primary key constraints</title> <p><indexterm>Primary
+key constraints</indexterm>A primary
 key defines the set of columns that uniquely identifies rows in a table.</p> <p>When
 you create a primary key constraint, none of the columns included in the primary
 key can have NULL constraints; that is, they must not permit NULL values.</p> <p>ALTER
@@ -88,8 +86,19 @@
 key if they were first defined as NOT NULL. NULL values are not allowed. If
 the column(s) contain NULL values, the system will not add the primary key
 constraint. See <xref href="rrefsqlj81859.dita#rrefsqlj81859"></xref> for more
information.</p> <p>A
-table can have at most one PRIMARY KEY constraint, but can have multiple UNIQUE
-constraints.</p> </section>
+table can have at most one PRIMARY KEY constraint.</p> </section>
+<section><title>Unique constraints</title><p><indexterm>Unique
constraints</indexterm>
+A UNIQUE constraint defines a set of columns that uniquely identify rows in a
+table only if all the key values are not NULL. If one or more key parts are
+NULL, duplicate keys are allowed. </p>
+<p>For example, if there is a UNIQUE constraint on <codeph>col1</codeph>
and
+<codeph>col2</codeph> of a table, the combination of the values held by
+<codeph>col1</codeph> and <codeph>col2</codeph> will be unique as
long
+as these values are not NULL. If one of <codeph>col1</codeph> and
+<codeph>col2</codeph> holds a NULL value, there can be another identical row
in
+the table.</p>
+<p>A table can have multiple UNIQUE constraints.</p>
+</section>
 <section><title>Foreign key constraints</title> <p><indexterm>Foreign
keys</indexterm><indexterm>Referential
 integrity<indexterm>via foreign keys</indexterm></indexterm>Foreign keys
provide
 a way to enforce the referential integrity of a database. A foreign key is
@@ -133,9 +142,11 @@
 automatically to enforce primary key, unique, and foreign key  constraints</indexterm></indexterm><indexterm>Indexes<indexterm>automatic
 creation of for primary key, unique, and foreign key constraints</indexterm></indexterm>UNIQUE,
 PRIMARY KEY, and FOREIGN KEY constraints generate indexes that enforce or
-"back" the constraint (and are sometimes called <i>backing indexes</i>). UNIQUE
-and PRIMARY KEY constraints generate unique indexes. FOREIGN KEY constraints
-generate non-unique indexes. Therefore, if a column or set of columns has
+"back" the constraint (and are sometimes called <i>backing indexes</i>).
+PRIMARY KEY constraints generate unique indexes. FOREIGN KEY constraints
+generate non-unique indexes. UNIQUE constraints generate unique indexes if
+all the columns are non-nullable, and they generate non-unique indexes if
+one or more columns are nullable. Therefore, if a column or set of columns has
 a UNIQUE, PRIMARY KEY, or FOREIGN KEY constraint on it, you do not need to
 create an index on those columns for performance. <ph conref="../conrefs.dita#prod/productshortname"></ph>
has
 already created it for you. See <xref href="rrefsqlj20937.dita#rrefsqlj20937/sqlj27363"></xref>.</p>

Modified: db/derby/docs/trunk/src/ref/rrefsqlj81859.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/ref/rrefsqlj81859.dita?rev=643094&r1=643093&r2=643094&view=diff
==============================================================================
--- db/derby/docs/trunk/src/ref/rrefsqlj81859.dita (original)
+++ db/derby/docs/trunk/src/ref/rrefsqlj81859.dita Mon Mar 31 11:40:41 2008
@@ -97,7 +97,7 @@
 the ALTER TABLE ADD COLUMN statement. However, a column with a NOT NULL constraint
 can be added to an existing table if you give a default value; otherwise,
 an exception is thrown when the ALTER TABLE statement is executed. </p><p>Just
-as in CREATE TABLE, if the column definition includes a unique or primary
+as in CREATE TABLE, if the column definition includes a primary
 key constraint, the column cannot contain null values, so the NOT NULL attribute
 must also be specified (SQLSTATE 42831).</p><note>If a table has an UPDATE
 trigger without an explicit column list, adding a column to that table in
@@ -172,7 +172,7 @@
     <p>You can add the NOT NULL constraint to an existing column. To do so
         there must not be existing NULL values for the column in the table.</p>
     <p>You can remove the NOT NULL constraint from an existing column. To do
-        so the column must not be used in a PRIMARY KEY or UNIQUE constraint.</p></li>
+        so the column must not be used in a PRIMARY KEY constraint.</p></li>
 <li>Changing the default value for a column.</li>
 </ul></p></section>
 <section><title>Setting defaults</title><p>You can specify a default
value



Mime
View raw message