Alterando tipo on the fly

Veja nesta dica como alterar tipo de dados on the fly.

Alterando tipo on the fly

Versões recentes do Oracle indicam que você pode alterar tipo on the fly sem a necessidade de recriá-lo. Aqui temos um simples exemplo de como fazê-lo

SQL> create type T1 as object ( x number, y number ) not final;
  2  /
Type created.
SQL> create type T2 as table of T1;
  2  /
Type created.
SQL> create or replace type T1 as object ( x number, y number, z number );
  2  /
create or replace type T1 as object ( x number, y number, z number );
*
ERROR at line 1:
ORA-02303: cannot drop or replace a type with type or table dependents

Neste caso, você precisa utilizar a cláusula ALTER TYPE:

SQL> alter type T1 add attribute ( z number );
alter type T1 add attribute ( z number )
*
ERROR at line 1:
ORA-22312: must specify either CASCADE or INVALIDATE option
SQL> alter type T1 add attribute ( z number ) cascade;
Type altered.

 

Ebook exclusivo
Dê um upgrade no início da sua jornada. Crie sua conta grátis e baixe o e-book

Artigos relacionados