René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

Substitutable column clause [Oracle SQL]

[ element ] is of [ type ] (only type-name)
or
[ not ] substitutable at all levels
The substitutable column clause appears as part of object type column properties, the nested table column properties or the varray column properties.

Example

create type base_type as object (
  num number,
  dt  date
) not final
/

create type deriv_type under base_type (
  str varchar2(10) 
)
/
create table allows_subtypes (
  id  number,
  bt  base_type
)
column bt substitutable at all levels;
create table does_not_allow_subtypes (
  id  number,
  bt  base_type
)
column bt is of type (only base_type);
begin
  insert into allows_subtypes values (1, base_type(1,sysdate));
  insert into allows_subtypes values (1, deriv_type(1,sysdate, 'x'));
end;
/
begin 
  insert into does_not_allow_subtypes values (1, base_type(1,sysdate));

  -- Next line would cause ORA-00932 if uncommented
  -- insert into does_not_allow_subtypes allows_subtypes values (1, deriv_type(1,sysdate, 'x'));
end;
/

Unclear

The following statement, imho correct according to the docs, causes a ORA-00905: missing keyword.
create table unclear (
  id  number,
  bt  base_type
)
column bt element is of type (only base_type);