Your browser does not support JavaScript. This help page requires JavaScript to render correctly.
Skip Headers
Previous
Previous
 
Next
Next

Example: Adding a New Table Constraint

In this example, you add a table constraint to the purchase_orders table that you created in "Example: Creating a Table". To enforce the rule that the po_date_received value must be either the same day as, or later than, the value of po_date, you add a check constraint.

Note: You can also add constraints during table creation, as shown in "Example: Creating a Table". In that example, you added a primary key constraint.

To add a table constraint to the PURCHASE_ORDERS table:

  1. Go to the Database Home page, logging in as user nick or as user SYSTEM.

    See "Accessing the Database Home Page".

  2. At the top of the page, click Schema to view the Schema subpage.

  3. In the Database Objects section, click callbackTables.

    The Tables page appears.

  4. In the Schema field, enter nick and then click Go.

    All tables owned by user nick are displayed.

  5. Select the PURCHASE_ORDERS table, and then click Edit.

    The Edit Table page appears.

  6. Click Constraints to display the Constraints subpage.

  7. In the list adjacent to the Add button, select CHECK, and then click Add.

    The Add CHECK Constraint page appears.

  8. In the Name field, enter po_check_rcvd_date, overwriting the system-assigned default name.

  9. In the Check Condition field, enter the following:

    po_date_received >= po_date
    

    This expression indicates that po_date_received must be greater than or equal to po_date. For date columns, this is equivalent to stating that po_date_received must be on the same day as, or later than, po_date.

  10. Click Continue

    The new constraint appears on the Constraints subpage.

  11. Click Apply.

    A confirmation message appears.

Related Topics

About Tables

About Table-Level Constraints

Modifying Table Attributes