2016-06-21 03:06:44 -05:00
|
|
|
.. _exclusion_constraint_dialog:
|
2016-05-27 11:13:36 -05:00
|
|
|
|
2018-06-15 03:14:12 -05:00
|
|
|
************************************
|
2019-03-08 09:29:05 -06:00
|
|
|
`Exclusion Constraint Dialog`:index:
|
2018-06-15 03:14:12 -05:00
|
|
|
************************************
|
2016-05-27 11:13:36 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Use the *Exclusion constraint* dialog to define or modify the behavior of an
|
|
|
|
exclusion constraint. An exclusion constraint guarantees that if any two rows
|
|
|
|
are compared on the specified column or expression (using the specified
|
|
|
|
operator), at least one of the operator comparisons will return false or null.
|
2016-05-27 11:13:36 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
The *Exclusion constraint* dialog organizes the development of an exclusion
|
|
|
|
constraint through the following dialog tabs: *General*, *Definition*, and
|
|
|
|
*Columns*. The *SQL* tab displays the SQL code generated by dialog selections.
|
2018-01-11 10:58:30 -06:00
|
|
|
|
2016-05-27 11:13:36 -05:00
|
|
|
.. image:: images/exclusion_constraint_general.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Exclusion constraint dialog general tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
2016-05-27 11:13:36 -05:00
|
|
|
|
|
|
|
Use the fields in the *General* tab to identify the exclusion constraint:
|
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Use the *Name* field to provide a descriptive name for the exclusion
|
|
|
|
constraint. The name will be displayed in the *pgAdmin* tree control.
|
2016-05-27 11:13:36 -05:00
|
|
|
|
|
|
|
Click the *Definition* tab to continue.
|
|
|
|
|
|
|
|
.. image:: images/exclusion_constraint_definition.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Exclusion constraint dialog definition tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
2016-05-27 11:13:36 -05:00
|
|
|
|
|
|
|
Use the fields in the *Definition* tab to define the exclusion constraint:
|
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Use the drop-down listbox next to *Tablespace* to select the tablespace in
|
|
|
|
which the index associated with the exclude constraint will reside.
|
|
|
|
* Use the drop-down listbox next to *Access method* to specify the type of
|
|
|
|
index that will be used when implementing the exclusion constraint:
|
2018-01-11 10:58:30 -06:00
|
|
|
|
|
|
|
* Select *gist* to specify a GiST index.
|
|
|
|
* Select *spgist* to specify a space-partitioned GiST index.
|
|
|
|
* Select *btree* to specify a B-tree index.
|
|
|
|
* Select *hash* to specify a hash index.
|
2016-05-27 11:13:36 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Use the *Fill Factor* field to specify a fill factor for the table and
|
|
|
|
associated index. The fill factor is a percentage between 10 and 100. 100
|
|
|
|
(complete packing) is the default.
|
|
|
|
* Move the *Deferrable?* switch to the *Yes* position to specify that the
|
|
|
|
timing of the constraint is deferrable, and can be postponed until the end of
|
|
|
|
the statement. The default is *No*.
|
|
|
|
* If enabled, move the *Deferred?* switch to the *Yes* position to specify the
|
|
|
|
timing of the constraint is deferred to the end of the statement. The default
|
|
|
|
is *No*.
|
|
|
|
* Use the *Constraint* field to provide a condition that a row must satisfy to
|
|
|
|
be included in the table.
|
2016-05-27 11:13:36 -05:00
|
|
|
|
|
|
|
Click the *Columns* tab to continue.
|
|
|
|
|
|
|
|
.. image:: images/exclusion_constraint_columns.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Exclusion constraint dialog columns tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
|
|
|
|
2020-12-24 01:20:57 -06:00
|
|
|
Use the fields in the *Columns* tab to specify the column(s) or expression(s)
|
|
|
|
to which the constraint applies. Use the *Is expression ?* switch to enable
|
|
|
|
expression text input. Use the drop-down listbox next to *Column*
|
|
|
|
to select a column. Once the *Column* is selected or the *Expression* is
|
|
|
|
entered then click the *Add* icon (+) to provide details of the action on the
|
|
|
|
column/expression:
|
|
|
|
|
|
|
|
* The *Col/Exp* field is populated with the selection made in the *Column*
|
|
|
|
drop-down listbox or the *Expression* entered.
|
2019-03-08 09:29:05 -06:00
|
|
|
* If applicable, use the drop-down listbox in the *Operator class* to specify
|
|
|
|
the operator class that will be used by the index for the column.
|
|
|
|
* Move the *DESC* switch to *DESC* to specify a descending sort order. The
|
|
|
|
default is *ASC* which specifies an ascending sort order.
|
|
|
|
* Use the *NULLs order* column to specify the placement of NULL values (when
|
|
|
|
sorted). Specify *FIRST* or *LAST*.
|
|
|
|
* Use the drop-down list next to *Operator* to specify a comparison or
|
|
|
|
conditional operator.
|
|
|
|
|
|
|
|
Use *Include columns* field to specify columns for *INCLUDE* clause of the
|
|
|
|
constraint. This option is available in Postgres 11 and later.
|
2018-07-19 07:13:37 -05:00
|
|
|
|
2016-05-27 11:13:36 -05:00
|
|
|
Click the *SQL* tab to continue.
|
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Your entries in the *Exclusion Constraint* dialog generate a SQL command (see
|
|
|
|
an example below). Use the *SQL* tab for review; revisit or switch tabs to make
|
|
|
|
any changes to the SQL command.
|
2016-05-27 11:13:36 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Example
|
|
|
|
*******
|
2016-05-27 11:13:36 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
The following is an example of the sql command generated by user selections in
|
|
|
|
the *Exclusion Constraint* dialog:
|
2016-05-27 11:13:36 -05:00
|
|
|
|
|
|
|
.. image:: images/exclusion_constraint_sql.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Exclusion constraint dialog sql tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
2016-05-27 11:13:36 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
The example shown demonstrates creating an exclusion constraint named
|
2021-09-26 11:33:11 -05:00
|
|
|
*ex_dept_no*. The constraint uses a btree index.
|
2016-05-27 11:13:36 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Click the *Info* button (i) to access online help.
|
2016-05-27 11:13:36 -05:00
|
|
|
* Click the *Save* button to save work.
|
2021-09-26 11:33:11 -05:00
|
|
|
* Click the *Close* button to exit without saving work.
|
|
|
|
* Click the *Reset* button to restore configuration parameters.
|