I am bit stucked with my Lab from Object-Relational dtb. I have this hierarchy:
SUPERTYPE EMPLOYEE_TYPE3
------------------------------
empno number(4)
ename varchar(10),
job varchar(9),
hiredate date,
sal number(7, 2),
deptno number(2)
SUBTYPE MANAGER_TYPE3
------------------------------
office varchar(6),
car varchar(10)
SUBTYPE SALESMAN_TYPE3
------------------------------
comm number(7, 2)
SUBTYPE STAFF_TYPE3
------------------------------
office varchar(6)
And I made table for every subtype under the employee_type3
. What I need to do is to create a view ALL_EMPLOYEES
that includes data from all employee subtypes. The view should contain all the columns from each subtype. It is obvious that in some columns will be null values.
Does anyone know how to do such view? I think that union is useless here because I have different number of columns.
Thank you very much for your help!
You indeed use a union (but a
UNION ALL
).You null-extend all rows so they have the same structure:
Note, that I included a discriminator so you can filter on the type (or even determine it).