Re: Unique constraint over 2 columns with allowable NULLs
- From: Maxim Demenko <mdemenko@xxxxxxxxx>
- Date: Fri, 30 Nov 2007 14:09:44 +0100
mikew01 schrieb:
Thanks for the replies, but in both cases you have put different data
into the non null column so the uniqueness constraint has not been
violated.
Following on from the previous example...
SQL> CREATE TABLE t (
2 col1 NUMBER,
3 col2 NUMBER);
Table created.
SQL> ALTER TABLE t
2 ADD CONSTRAINT uc_t
3 UNIQUE (col1, col2)
4 USING INDEX;
Table altered.
SQL> INSERT INTO t VALUES (1, NULL);
1 row created.
What might happen is this again
SQL> INSERT INTO t VALUES (1, NULL);
Which will fail with Oracle
Ive tried using a trigger to check the values when they are being
updated but I get a mutating table error.
create unique index t_uidx on t(nvl2(col1+col2,col1,null),nvl2(col1+col2,col2,null));
Best regards
Maxim
.
- References:
- Unique constraint over 2 columns with allowable NULLs
- From: mikew01
- Re: Unique constraint over 2 columns with allowable NULLs
- From: DA Morgan
- Re: Unique constraint over 2 columns with allowable NULLs
- From: mikew01
- Unique constraint over 2 columns with allowable NULLs
- Prev by Date: Re: SGA
- Next by Date: Re: Oracle Linux/Virtualization Software
- Previous by thread: Re: Unique constraint over 2 columns with allowable NULLs
- Next by thread: Need sql server DBA -CA.9 Months
- Index(es):
Relevant Pages
|
|