Specifying Constraints on XMLType Columns
Hi
My test environment: 9.2.0.2.0 for Linux
I'm trying to create different type of constraints on a XMLType column. The table definition is:
CREATE TABLE invoice_or (content xmltype)
xmltype content STORE AS OBJECT RELATIONAL
XMLSCHEMA "invoice.xsd"
ELEMENT "Invoice";
I can create a check constraint like the following:
SQL> ALTER TABLE invoice_or ADD CONSTRAINT invoice_or_valid
2 CHECK (xmlisvalid(content) = 1);
But I didn't manage to create a unique key or a foreign key. Here an example:
SQL> ALTER TABLE invoice_or ADD CONTRAINT invoice_or_uk
2 UNIQUE (content.xmldata.invoice_id);
UNIQUE (content.xmldata.invoice_id)
*
ERROR at line 2:
ORA-01735: invalid ALTER TABLE option
Notice that the following select is ok:
SQL> select i.content.xmldata.invoice_id from invoice_or i;
SYS_NC00005$.INVOICE_ID
-----------------------
1001
1002
I have no problem if I use a xmltype table. Are such constraint not supported? How to define them?
Any hint is welcome... thanks!
Chris