简体   繁体   中英

Oracle nested table constraints

how to add CHECK constraints into a nested table in oracle?

Object types:

Depend_t (depname: varchar2(12), gender: char(1), bdate: date, relationship:varchar2(10))

Dependtb_t table of Depend_t

Emp_t (eno: number(4), ename: varchar2(15), edept: ref dept_t, salary: number(8,2),

dependents: dependtb_t)

Dept_t (dno: number(2), dname: varchar2(12), mgr ref emp_t)
Proj_t (pno: number(4), pname: varchar2(15), pdept ref dept_t, budget: number(10,2))
Work_t (wemp: ref emp_t, wproj: ref proj_t, since: date, hours: number(4,2))

Tables:

Emp of Emp_t (eno primary key, edept references dept, nested table dependents store as dependent_tb)

Dept of Dept_t (dno primary key, mgr references emp)
Proj of Proj_t (pno primary key, pdept references dept)
Works of Works_t (wemp references emp, wproj references proj)

The Emp, Dept, and Proj tables contain tuples for all employees, departments and projects respectively. The attributes of Emp are employee number (eno), name (ename), employee's department (edept), salary and the set of dependents stored as a nested table. The relationship attribute may have only 'SPOUSE' or 'CHILD' as values, gender may be 'M' or 'F' , and bdate records the birth date of the dependant.

here how could add the 'M' or 'F' constraint in nested table?

From Oracle 12C SQL Reference :

Restrictions on Check Constraints

Check constraints are subject to the following restrictions:

...

  • Conditions of check constraints cannot contain the following constructs:

    ...

    • Nested table columns or attributes ...

This is one of many reasons why nested tables are almost never used in real databases, only in courses that explore all the features of Oracle!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM