oracleÖв»¼´ÊÇnullºÍ is not nullÇø±ð
not null ÊÇÁÐÔ¼Êø£¬Õ¥È¡ null Öµ²åÈ룻is not null ÊǼì²é²Ù×÷·û£¬ÆÀ¹ÀÁÐÊÇ·ñ²»°üÀ¨ null Öµ¡£
Oracle ÖÐ NOT NULL ºÍ IS NOT NULL µÄÇø±ð
NOT NULL ºÍ IS NOT NULL ÊÇ Oracle ÖÐÓÃÓÚÖ¸¶¨ÁÐÔ¼ÊøµÄÁ½¸öÏà¹Øµ«²»ÏàͬµÄ¹ØϵÔËËã·û¡£
NOT NULL
NOT NULL Ô¼ÊøÖ¸¶¨Áв»¿É°üÀ¨ NULL Öµ¡£ÕâÒâζןÃÁбØÐèʼÖÕ°üÀ¨Ò»¸ö·Ç¿ÕÖµ¡£ÈôÊÇʵÑ齫 NULL Öµ²åÈë¾ßÓÐ NOT NULL Ô¼ÊøµÄÁУ¬Ôò Oracle ½«Òý·¢¹ýʧ¡£
IS NOT NULL
ÁíÒ»·½Ã棬IS NOT NULL ²Ù×÷·ûÓÃÓÚ¼ì²éÁÐÊÇ·ñ²»°üÀ¨ NULL Öµ¡£Ëü·µ»ØÒ»¸ö²¼¶ûÖµ£ºÈôÊÇÁв»°üÀ¨ NULL Öµ£¬Ôò·µ»Ø TRUE£»ÈôÊÇ°üÀ¨ NULL Öµ£¬Ôò·µ»Ø FALSE¡£
Òªº¦Çø±ð
NOT NULL ºÍ IS NOT NULL Ö®¼äµÄÖ÷ÒªÇø±ðÔÚÓÚ£º
Ô¼ÊøÓë¼ì²é£ºNOT NULL ÊÇÒ»¸öÔ¼Êø£¬ÓÃÓÚ½ç˵ÁеÄÐÐΪ£¬¶ø IS NOT NULL ÊÇÒ»¸ö¼ì²é²Ù×÷·û£¬ÓÃÓÚÆÀ¹ÀÁеÄÄ¿½ñÄÚÈÝ¡£
NULL ²åÈ룺NOT NULL Ô¼Êøեȡ NULL ÖµµÄ²åÈ룬¶ø IS NOT NULL ÔËËã·û²»»á×èÖ¹²åÈë NULL Öµ¡£
Ó÷¨
ËäÈ»Á½¸ö²Ù×÷·û¶¼ÓÃÓÚÈ·±£ÁаüÀ¨·Ç NULL Öµ£¬µ«ËüÃÇÔÚ²î±ðÇéÐÎÏÂʹÓãº
½ç˵ÁÐÔ¼Êø£ºNOT NULL Ô¼ÊøÓÃÓÚÔÚ½¨Éè±íʱ½ç˵ÁÐÐÐΪ¡£
¼ì²éÁÐÄÚÈÝ£ºIS NOT NULL ²Ù×÷·ûÓÃÓÚÔÚÅÌÎÊÖмì²éÁÐÊÇ·ñ²»°üÀ¨ NULL Öµ¡£
ʾÀý
ÒÔÏÂʾÀýÑÝʾÁËÕâÁ½¸ö²Ù×÷·ûÖ®¼äµÄÇø±ð£º
CREATE TABLE MyTable ( id NUMBER NOT NULL, name VARCHAR2(255) ); INSERT INTO MyTable (id) VALUES (1); -- OK INSERT INTO MyTable (name) VALUES (NULL); -- Error SELECT * FROM MyTable WHERE name IS NOT NULL; -- Returns row with non-NULL name
µÇ¼ºó¸´ÖÆ
ÒÔÉϾÍÊÇoracleÖв»¼´ÊÇnullºÍ is not nullÇø±ðµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡