At the site where I am currently working Oracle Designer is used. The version they have here, Designer 10, does not supprt XMLType and this posed a
problem at first.
Table script could not be generated because it is not possible to define a column of XMLType. What we did was create a user defined type called XMLType and use this fake-XMLType
for the table definitions. When you generate a table-creation script, it will look like this:
CREATE TABLE XML_TEST<br /> (ID NUMBER(10,0) NOT NULL<br /> ,FAKE_XML XMLTYPE<br /> )<br />/<br />
But that is not all, the generator also creates a script for the XMLType itself:
PROMPT Creating Object Type 'XMLTYPE'<br />CREATE OR REPLACE TYPE XMLTYPE AS OBJECT<br /> (X INT<br /> )<br />/<br />
If you are not careful this fake XMLType is created in the database and none of your XMLType methods will work properly, if at all.
And guess what happened yesterday? We forgot to remove the "create-type" script, so the fake-XMLType was created and all fell down. Removing the fake-XMLType was the only option, but
you are not allowed to do so when dependents exist, like a column in a table.
Where did it go?
To remove the fake-XMLType I issued
SQL> drop type xmltype<br /> 2 /<br />drop type xmltype<br />*<br />ERROR at line 1:<br />ORA-02303: cannot drop or replace a type with type or table dependents<br />
That obviously didn’t work, so I force dropped it:
SQL> drop type xmltype force;<br /><br />Type dropped.<br /><br />SQL><br />
And that did the job…. and more. It also removed the columns in the table that were of the XMLType. So the table above changed to:
SQL> desc xml_test<br /> Name Null? Type<br /> ---------- -------- ----------<br /> ID NOT NULL NUMBER(10)<br /><br />SQL><br />
Actually the columns was not dropped, but marked as UNUSED and this columns become inaccessible.
(more info in the documentation)
To find out how many columns are marked as UNUSED, you can query the datadictionary view USER_UNUSED_COL_TABS. It is also
possible to explicitly mark a column as UNUSED explicitly:
alter table table_name set unused (column_name);<br />
It is not possible reverse this action, you can not mark the column as USED.
Live and learn
Instead of being smart and fix the problem with a single statement, the problem only got worse. Instead of getting rid of the fake XMLtype by dropping it, I had
to recreate the tables as well. If only I had paid a little more attention when I executed the create-scripts…
Oh well, you live and learn. I won’t do that again… until the next time.