Constraints let you reduce data entry errors by verifying data before inserting the data into a table.

You create constraints when you create a table, or you can add them later.

Enter SQL fragments to define a constraint.

You are logged in to your organization as an organization administrator or user with database privileges.

The database Console is open.

The table on which to create the constraint exists.

You expanded the schema in the left pane, and selected Tables.

1

Click the table to select it, and click the gear icon.

2

Select Create > Constraint.

3

Select a constraint to create.

Constraint Type

Description

Check

Limits the values or value range that can be inserted in a column.

Unique

Ensures that a column or set of columns is unique.

Primary key

Uniquely identifies each row in a table. You can have only one primary key per table.

Foreign key

Points to a primary key in another table.

4

Complete the dialog and click OK.

Data Director creates the constraint.

A check constraint evaluates to a Boolean value. Use Check constraints to determine whether a value entered for a column meets a specific truth-type requirement. For example, suppose that you create a column that must be a positive integer, such as a product price. You can create a Check constraint to return TRUE when the product price is greater than 0, and to return FALSE when the product price is less than 0. The Check constraint ensures that if a user tries to enter a negative product price, the data entry operation fails with a SQL error.

1

Click a table to select it.

2

Click the gear icon, and select Create > Constraint.

3

Select Check Constraint.

1

Type a name for the constraint, such as check_positive_price.

2

Enter the constraint in the Check text box.

3

(Optional) Enter a comment that describes the constraint.

4

Click OK.

Data Director creates the constraint.