SQL*Plus: Release 10.2.0.1.0 - Production on Sat Mar 4 01:23:08 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
SQL> CREATE TABLE T (P NUMBER PRIMARY KEY, A NUMBER);
Table created.
SQL> ALTER TABLE T ADD CONSTRAINT CT CHECK (A>0) DEFERRABLE;
Table altered.
SQL> SET CONSTRAINT CT DEFERRED;
Constraint set.
SQL> INSERT INTO T VALUES (1,-1);
1 row created.
SQL> DELETE FROM T;
1 row deleted.
SQL> SET CONSTRAINT CT IMMEDIATE;
Constraint set.
SQL> COMMIT;
Commit complete.
Everything working as intended. Same example, but with IOT:
SQL> CREATE TABLE T (P NUMBER PRIMARY KEY, A NUMBER) ORGANIZATION
INDEX;
Table created.
SQL> ALTER TABLE T ADD CONSTRAINT CT CHECK (A>0) DEFERRABLE;
Table altered.
SQL> SET CONSTRAINT CT DEFERRED;
Constraint set.
SQL> INSERT INTO T VALUES (1,-1);
1 row created.
SQL> DELETE FROM T;
1 row deleted.
SQL> SET CONSTRAINT CT IMMEDIATE;
SET CONSTRAINT CT IMMEDIATE
*
ERROR at line 1:
ORA-02290: check constraint (LORENAI.CT) violated
Is this normal? It's some undocumented restricton (or documented, but
hard to find), or a bug?
Just a funny follow-up.
I was running your test case, and at the end,
I tried to switch to the sys account (for reasons
that aren't significant). This is what happened
on both 10.2.0.1 and 9.2.0.6
++++++++++++++++++
-- your test running
1 row deleted.
SQL> SET CONSTRAINT CT IMMEDIATE;
SET CONSTRAINT CT IMMEDIATE
*
SQL> connect / as sysdba
ERROR:
ORA-02091: transaction rolled back
ORA-02290: check constraint (TEST_USER.CT) violated
ERROR:
ORA-24313: user already authenticated
Warning: You are no longer connected to ORACLE.
+++++++++++++++++++
I'd call it a bug and raise an SR.
Possibly it's happening because the rowindex entry
is cleared on the heap table, so the row ceases to
exist, whereas the IOT is an index, so the delete
simply marks as 'flagged for delete' and is therefore
(accidentally) still visible as a potentially bad entry.
--
Regards
Jonathan Lewis
http://www.oracle.com/technology/community/oracle_ace/ace1.html#lewis
The Co-operative Oracle Users' FAQ
http://www.jlcomp.demon.co.uk/faq/ind_faq.html
Cost Based Oracle: Fundamentals
http://www.jlcomp.demon.co.uk/cbo_book/ind_book.html
Anyway, I can't raise a TAR, because I'm not a customer (as you can
see, I use 10gXE). Or is there way for XE users to report bugs too?
Update in an index (or IOT) is not really an update but delette+insert.
So you're in the same problem.
Regards
Michel Cadot