Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Attribute Level Constraint
Khurram wrote:
> My question Why it is accepting NULL values though i have declared NOT
> NULL to table
> column name??
The constraint says that the COLUMN must not be null:
SQL> INSERT INTO t VALUES (2,NULL);
INSERT INTO t VALUES (2,NULL)
*
ERROR at line 1:
ORA-01400: cannot insert NULL into ("XX"."T"."NAME")
It does not say that the attributes of the column cannot be null. There is a subtle but real difference between NULL and mytype(NULL,NULL).
However, you can create constraints at the attribute level:
SQL> alter table t add constraint fname_chk check (name.fname is not null);
Table altered.
SQL> alter table t add constraint lname_chk check (name.lname is not null);
Table altered.
SQL> INSERT INTO t VALUES (2,mytype(NULL,NULL));
INSERT INTO t VALUES (2,mytype(NULL,NULL))
*
ERROR at line 1:
ORA-02290: check constraint (XX.LNAME_CHK) violated
Received on Fri Jun 23 2006 - 06:13:44 CDT
![]() |
![]() |