mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
51 lines
2.7 KiB
ReStructuredText
51 lines
2.7 KiB
ReStructuredText
.. _create_domain_constraint:
|
|
|
|
**************************
|
|
Create - Domain Constraint
|
|
**************************
|
|
|
|
Use the *Create - Domain Constraint* dialog to create a domain constraint. The *Create - Domain Constraint* dialog implements options of the ALTER DOMAIN command. For more information about the ALTER DOMAIN command, see PostgreSQL core documentation available at:
|
|
|
|
http://www.postgresql.org/docs/9.5/static/sql-alterdomain.html
|
|
|
|
The *Create - Domain Constraint* 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.
|
|
|
|
.. image:: images/create_domain_constraint_general.png
|
|
:align: center
|
|
|
|
Use the fields in the *General* tab to identify the domain constraint:
|
|
* Use the *Name* field to add a descriptive name for the constraint. The name will be displayed in the *pgAdmin* tree control.
|
|
* Store notes about the constraint in the *Comments* field.
|
|
|
|
Click the *Definition* tab to continue.
|
|
|
|
.. image:: images/create_domain_constraint_definition.png
|
|
:align: center
|
|
|
|
Use the fields in the *Definition* tab to define the domain constraint:
|
|
|
|
* Use the *Check* field to write a CHECK expression. A CHECK clause specifies a constraint that the domain must satisfy. A constraint must be an expression producing a Boolean result; include the key word VALUE to refer to the value being tested. Only those expressions that evaluate to TRUE or UNKNOWN succeed. A CHECK expressions cannot contain subqueries or refer to variables other than VALUE. When a domain has multiple CHECK constraints, they will be tested in alphabetical order by name.
|
|
* 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*.
|
|
|
|
Click the *SQL* tab to continue.
|
|
|
|
.. image:: images/create_domain_constraint_sql.png
|
|
:align: center
|
|
|
|
Your entries in the *Create - Domain Constraint* dialog generate a SQL command; you can review the command on the *SQL* pane.
|
|
|
|
* Click the *Info* button (i) to access online help.
|
|
* Click the *Save* button to save work.
|
|
* Click the *Cancel* button to exit without saving work.
|
|
* Click the *Reset* button to restore configuration parameters.
|
|
|
|
Example
|
|
=======
|
|
|
|
The following is an example of the sql command generated by user selections in the *Create - Domain Constraint* dialog:
|
|
|
|
.. image:: images/create_domain_constraint_sql_example.png
|
|
|
|
The example shown demonstrates creating a domain constraint on the domain *timesheets* named *weekday*. It constrains a value to equal *Monday*, *Tuesday*, *Wednesday*, *Thursday*, or *Friday*.
|
|
|