2016-06-21 03:06:44 -05:00
|
|
|
.. _domain_constraint_dialog:
|
2016-05-13 08:43:57 -05:00
|
|
|
|
2018-06-15 03:14:12 -05:00
|
|
|
**********************************
|
|
|
|
`Domain Constraints Dialog`:index:
|
|
|
|
**********************************
|
2016-05-13 08:43:57 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Use the *Domain Constraints* dialog to create or modify a domain constraint. A
|
|
|
|
domain constraint confirms that the values provided for a domain meet a defined
|
|
|
|
criteria. The *Domain Constraints* dialog implements options of the ALTER DOMAIN
|
|
|
|
command.
|
2016-05-13 08:43:57 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
The *Domain Constraints* dialog organizes the development of a domain constraint
|
|
|
|
through the following dialog tabs: *General* and *Definition*. The *SQL* tab
|
|
|
|
displays the SQL code generated by dialog selections.
|
2016-05-13 08:43:57 -05:00
|
|
|
|
2016-05-20 15:39:21 -05:00
|
|
|
.. image:: images/domain_constraint_general.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Domain constraint dialog general tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
2018-01-11 10:58:30 -06:00
|
|
|
|
2016-05-13 08:43:57 -05:00
|
|
|
Use the fields in the *General* tab to identify the domain constraint:
|
2016-05-24 07:47:35 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Use the *Name* field to add a descriptive name for the constraint. The name
|
|
|
|
will be displayed in the *pgAdmin* tree control.
|
2016-05-24 07:47:35 -05:00
|
|
|
* Store notes about the constraint in the *Comment* field.
|
2016-05-13 08:43:57 -05:00
|
|
|
|
|
|
|
Click the *Definition* tab to continue.
|
|
|
|
|
2016-05-20 15:39:21 -05:00
|
|
|
.. image:: images/domain_constraint_definition.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Domain constraint dialog general tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
2018-01-11 10:58:30 -06:00
|
|
|
|
2016-05-13 08:43:57 -05:00
|
|
|
Use the fields in the *Definition* tab to define the domain constraint:
|
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Use the *Check* field to provide a CHECK expression. A CHECK expression
|
|
|
|
specifies a constraint that the domain must satisfy. A constraint must produce
|
|
|
|
a Boolean result; include the key word VALUE to refer to the value being
|
|
|
|
tested. Only those expressions that evaluate to TRUE or UNKNOWN will succeed.
|
|
|
|
A CHECK expression cannot contain subqueries or refer to variables other than
|
|
|
|
VALUE. If a domain has multiple CHECK constraints, they will be tested in
|
|
|
|
alphabetical order.
|
|
|
|
* Move the *Validate?* switch to the *No* position to mark the constraint NOT
|
|
|
|
VALID. If the constraint is marked NOT VALID, the constraint will not be
|
|
|
|
applied to existing column data. The default value is *Yes*.
|
2016-05-13 08:43:57 -05:00
|
|
|
|
|
|
|
Click the *SQL* tab to continue.
|
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Your entries in the *Domain Constraints* 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-24 07:47:35 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Example
|
|
|
|
*******
|
2016-05-24 07:47:35 -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 *Domain Constraints* dialog:
|
2016-05-24 07:47:35 -05:00
|
|
|
|
2016-05-20 15:39:21 -05:00
|
|
|
.. image:: images/domain_constraint_sql.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Domain constraint dialog general tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
2016-05-24 07:47:35 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
The example shown demonstrates creating a domain constraint on the domain
|
|
|
|
*timesheets* named *weekday*. It constrains a value to equal *Friday*.
|
2018-01-11 10:58:30 -06:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Click the *Info* button (i) to access online help.
|
2016-05-13 08:43:57 -05:00
|
|
|
* Click the *Save* button to save work.
|
|
|
|
* Click the *Cancel* button to exit without saving work.
|
|
|
|
* Click the *Reset* button to restore configuration parameters.
|
|
|
|
|
2018-01-11 10:58:30 -06:00
|
|
|
|
2016-05-13 08:43:57 -05:00
|
|
|
|