Check Dialog¶
Use the Check dialog to define or modify a check constraint. A check constraint specifies an expression that produces a Boolean result that new or updated rows must satisfy for an insert or update operation to succeed.
The Check dialog organizes the development of a check constraint through the General and Definition tabs. The SQL tab displays the SQL code generated by dialog selections.
Create Check dialog - General tab¶
Use the fields in the General tab to identify the check constraint:
Use the
Namefield to provide a descriptive name for the check constraint that will be displayed in theBrowsertree control. With PostgreSQL 9.5 forward, when a table has multiple check constraints, they will be tested for each row in alphabetical order by name and after NOT NULL constraints.Store notes about the check constraint in the
Commentfield.
Click the Definition tab to continue.
Create Check dialog - Definition tab¶
Use the fields in the Definition tab to define the check constraint:
Provide the expression that a row must satisfy in the
Checkfield.Move the
No Inherit?switch to theYesposition to specify this constraint is automatically inherited by a table’s children. The default isNo.Move the
Don't validate?switch to theNoposition to skip validation of existing data; the constraint may not hold for all rows in the table. The default isYes.
Click the SQL tab to continue.
Your entries in the Check 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.
Example
The following is an example of the sql command generated by user selections in the Check dialog:
Create Check dialog - SQL tab¶
The example shown demonstrates creating a check constraint named check_price on the price column of the products table. The constraint confirms that any values added to the column are greater than 0.
Click the
Infobutton (i) to access online help. View context-sensitive help in theTabbed browser, where a new tab displays the PostgreSQL core documentation.Click the
Savebutton to save work.Click the
Cancelbutton to exit without saving work.Click the
Resetbutton to restore configuration parameters.