DB2 database constraints (1)

Source: Internet
Author: User

The constraints are used by DB2 Universal Database (TM) DB2 UDB to implement business rules on data. This article describes the following types of constraints: non-null not null), unique, primary key, foreign key, and table check. In addition, there is another constraint named informational constraint. Different from the five constraints listed above, information constraints are not implemented by the database manager, but can be used by the SQL Compiler to improve query performance. In this article, I will focus only on the constraints listed above, but will not discuss information constraints.

You can define one or more DB2 UDB constraints when creating a new table, or you can define them later by changing the table. The create table statement is very complex. Although only a small part of the options are used to define constraints, when you view the statements in syntax Diagrams 1 and 2, those options seem quite complex. The DB2 Control Center makes constraints management easier and easier.

Figure 1. Partial syntax of the create table statement, showing the clause used to define constraints

Constraint definitions are associated with the databases they are applied to and stored in table 1 in the database directory ). You can query the database directory to retrieve and view the information. You can directly create a database connection from the command line. Remember to first establish a database connection). Similarly, you will find it easier to access this information through the Control Center.

The created constraints can be processed like other database objects. They have names and associated mode creator IDS), and can be removed in some cases ).

Figure 2. Partial syntax of the create table statement, showing the continued clause used to define constraints)


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.