Constraints are the mechanisms that Oracle database systems provide to restrict the integrity of data. Oracle 9i allows the creation of 5 constraints. See table 7.8.
To create a check constraint
(1) In the Manage Target navigator, follow the steps in the 7.6 section to modify the datasheet structure.
(2) Switch to the "Constraints" tab of the Edit table shown in Figure 7.61.
(3) The Sql of the above created check constraints Br>―――――――――――――――――――――――――――――――――――――
ALTER TABLE "SCOTT". " STUDENT "
ADD (CONSTRAINT "Graduate number CHECK constraint"
CHECK (student_id>=20020101 and student_id<=20030909))
―――――――――――――――――――――――――――――――――――――
"See CD files": \ 7th chapter \ Createcheck.sql.
(4) The reader can also perform the creation of a check constraint by performing createcheck.sql files directly in "Sqlplus Worksheet", as shown in Figure 7.62.
Test CHECK constraints
(1) In the Table Data editor interface shown in 7.63, click the Apply (P) button as shown in the contents of the diagram.
(2) The SQL code for the above input data is as follows.
―――――――――――――――――――――――――――――――――――――
INSERT into "SCOTT". " STUDENT "
("student_id", "NAME", "PROFESSIONAL", "Birthday", "director_id")
VALUES (20010101, ' Guixiaof ', ' Software engineering ', To_date (' 1 May-July -1971 ', ' dd-mon-yyyy HH:MI:SS AM '), 200201)
―――――――――――――――――――――――――――――――――――――
"See CD files": \ 7th chapter \ Testcheck.sql.
(3) The interface appears as shown in Figure 7.64.
(4) The reader can also perform a test of the Testcheck.sql file in the "Sqlplus Worksheet" to complete the check constraint, as shown in Figure 7.65.
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.