| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.tools -> Oracle Data Type constraints
How can I make a single element of a user type required?
The following is found in Oracle's Documentation to illustrate my question.
CREATE TYPE Person AS OBJECT (
first_name VARCHAR2(15),
last_name VARCHAR2(15),
birthday DATE,
home_address REF Address, -- shared with
other Person objects
phone_number VARCHAR2(15))
/
CREATE TABLE department (
dept_name VARCHAR2(20),
manager Person,
location VARCHAR2(20))
/
What would I do if I wanted to manager.make first_name and manager.last_name required in the department table?
I found that I can add any constraint other than not null to a specific component.
CREATE TABLE department (
dept_name VARCHAR2(20),
manager Person,
location VARCHAR2(20),
Constraint ATest UNIQUE (manager.first_name,
manager.last_name))
/
I realize that 'create table of' will allow 'not
null' constraints to be implemented without hassle
but then I would lose the benefit of inheritance
if I had to create a new data type for
every table.
Thanks in advance for your expert help!
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Thu Jun 29 2000 - 00:00:00 CDT
![]() |
![]() |