|
1 | | -<!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.96 2010/08/23 02:43:25 tgl Exp $ --> |
| 1 | +<!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.97 2010/08/26 21:08:35 tgl Exp $ --> |
2 | 2 |
|
3 | 3 | <chapter id="ddl"> |
4 | 4 | <title>Data Definition</title> |
@@ -544,6 +544,11 @@ CREATE TABLE products ( |
544 | 544 | </programlisting> |
545 | 545 | </para> |
546 | 546 |
|
| 547 | + <para> |
| 548 | + Adding a unique constraint will automatically create a unique btree |
| 549 | + index on the column or group of columns used in the constraint. |
| 550 | + </para> |
| 551 | + |
547 | 552 | <indexterm> |
548 | 553 | <primary>null value</primary> |
549 | 554 | <secondary sortas="unique constraints">with unique constraints</secondary> |
@@ -622,6 +627,11 @@ CREATE TABLE example ( |
622 | 627 | uniquely. |
623 | 628 | </para> |
624 | 629 |
|
| 630 | + <para> |
| 631 | + Adding a primary key will automatically create a unique btree index |
| 632 | + on the column or group of columns used in the primary key. |
| 633 | + </para> |
| 634 | + |
625 | 635 | <para> |
626 | 636 | A table can have at most one primary key. (There can be any number |
627 | 637 | of unique and not-null constraints, which are functionally the same |
@@ -831,6 +841,16 @@ CREATE TABLE order_items ( |
831 | 841 | column is changed (updated). The possible actions are the same. |
832 | 842 | </para> |
833 | 843 |
|
| 844 | + <para> |
| 845 | + Since a <command>DELETE</command> of a row from the referenced table |
| 846 | + or an <command>UPDATE</command> of a referenced column will require |
| 847 | + a scan of the referencing table for rows matching the old value, it |
| 848 | + is often a good idea to index the referencing columns. Because this |
| 849 | + is not always needed, and there are many choices available on how |
| 850 | + to index, declaration of a foreign key constraint does not |
| 851 | + automatically create an index on the referencing columns. |
| 852 | + </para> |
| 853 | + |
834 | 854 | <para> |
835 | 855 | More information about updating and deleting data is in <xref |
836 | 856 | linkend="dml">. |
@@ -875,6 +895,11 @@ CREATE TABLE circles ( |
875 | 895 | See also <link linkend="SQL-CREATETABLE-EXCLUDE"><command>CREATE |
876 | 896 | TABLE ... CONSTRAINT ... EXCLUDE</></link> for details. |
877 | 897 | </para> |
| 898 | + |
| 899 | + <para> |
| 900 | + Adding an exclusion constraint will automatically create an index |
| 901 | + of the type specified in the constraint declaration. |
| 902 | + </para> |
878 | 903 | </sect2> |
879 | 904 | </sect1> |
880 | 905 |
|
|
0 commit comments