Oracle provides a very useful clause check, which can automatically check data. It is used to create a table structure. For example:
Create Table worker
(Empno number (4) primary key,
Name varchar2 (10 ),
Age number (2) Check (age between 18 and 65 ),
/* Age Number (2) Check (age> = 18 and age <= 65 )*/
Lodging char (15) References lodging (lodging)
);
Create Table emp3
(Empno number (4) Constraint ABC primary key,
Ename varchar2 (10 ),
Job varchar2 (10 ),
Sex char (2) Check (sex = 'male' or sex = 'female '),
Mgr number (4 ),
Hiredate date,
Sal number (7, 2),/* salary */
Comm number (7, 2),/* bonus */
Deptno number (2 ),
Check (SAL + comm> 0 and Sal + comm <= 5000)
);
Suggestion: when designing the database table structure, we recommend that you analyze the value range of user data to describe the fields with a certain value range using check. To ensure the correctness of future data.