Comments on: Oracle RDBMS 11gR2 – alter or replace user defined types even when there are dependencies https://technology.amis.nl/2009/09/02/oracle-rdbms-11gr2-drop-and-replace-user-defined-types-even-when-there-are-dependencies/ Friends of Oracle and Java Wed, 08 Jul 2015 07:37:03 +0000 hourly 1 http://wordpress.org/?v=4.2.3 By: Marcel Hoefs https://technology.amis.nl/2009/09/02/oracle-rdbms-11gr2-drop-and-replace-user-defined-types-even-when-there-are-dependencies/#comment-5911 Mon, 05 Oct 2009 15:40:17 +0000 http://technology.amis.nl/blog/?p=6122#comment-5911 An alternative that works in 9i and 10g is the following:

SQL> create or replace
2 type person_t as object
3 ( first_name varchar2(30)
4 , last_name varchar2(30)
5 , birthdate date
6 )
7 /

Type is aangemaakt.

SQL> create or replace
2 type personal_relation_t as object
3 ( relationship_type varchar2(20)
4 , start_date date
5 , from_person person_t
6 , with_person person_t
7 )
8 /

Type is aangemaakt.

SQL> DROP TYPE person_t FORCE
2 /

Type is verwijderd.

SQL> create or replace
2 type person_t as object
3 ( first_name varchar2(30)
4 , last_name varchar2(30)
5 , birthdate date
6 , gender varchar2(1)
7 )
8 /

Type is aangemaakt.

SQL> DESC person_t
Naam Null? Type
—————————————– ——– —————————-
FIRST_NAME VARCHAR2(30)
LAST_NAME VARCHAR2(30)
BIRTHDATE DATE
GENDER VARCHAR2(1)

SQL> DESC personal_relation_t
Naam Null? Type
—————————————– ——– —————————-
RELATIONSHIP_TYPE VARCHAR2(20)
START_DATE DATE
FROM_PERSON PERSON_T
WITH_PERSON PERSON_T

]]>
By: radino https://technology.amis.nl/2009/09/02/oracle-rdbms-11gr2-drop-and-replace-user-defined-types-even-when-there-are-dependencies/#comment-5910 Thu, 03 Sep 2009 14:26:31 +0000 http://technology.amis.nl/blog/?p=6122#comment-5910 “Especially the fact that once a type has been created and has been referenced by other types, it cannot be altered. In order to change a small (or big thing) in a single type, it may be necessary to drop a whole bunch of types that are all somehow related to each other”

That’s not true. It can be altered by issuing ALTER TYPE statement (at least from 9i release 1. I don’t have older doc).
http://download.oracle.com/docs/cd/A91202_01/901_doc/server.901/a90125/statements_43.htm#2057830

tested in 11.1.0.6.0:

SQL> create type a as object(a number);
2 /

Type created

SQL> create type b as object(b a);
2 /

Type created

SQL> alter type a add attribute (c number) invalidate;

Type altered

SQL> alter type a add attribute (d number) cascade;

Type altered

SQL> desc a
Element Type
——- ——
A NUMBER
C NUMBER
D NUMBER

SQL> desc b
Element Type
——- —-
B A

]]>