oracle constraints(2)
oracle Ô¼ÊøµÄ״̬
oracleÔÚ´´½¨Ô¼ÊøºóĬÈÏ״̬ÊÇenabled VALIDATED
SQL> create table T2
2 (
3 VID NUMBER,
4 VNAME VARCHAR2(10) not null,
5 VSEX VARCHAR2(10) not null
6 )
7 /
Table created
SQL> alter table t2 add constraints PK_T primary key (vid);
Table altered
SQL> select t.constraint_name, t.status, t.validated from user_constraints t;
CONSTRAINT_NAME STATUS VALIDATED
------------------------------ -------- -------------
SYS_C003762 ENABLED VALIDATED
SYS_C003763 ENABLED VALIDATED
PK_T ENABLED VALIDATED
oracleÔ¼ÊøÒ»¹²ÓÐ4ÖÖ״̬:enabled validated, enabled novalidated, disadble validated, disable novalidated¡£
enabled validated ÊÇĬÈÏ״̬£¬±íʾÊý¾ÝÔÚÔ¼Êø´´½¨Ê±Òª¶ÔÊý¾Ý¿âÄÚµÄÊý¾Ý½øÐÐУÑé²¢ÇÒͬʱԼÊøºóÀ´²åÈëµÄÊý¾ÝÂú×ãÔ¼ÊøÌõ¼þ¡£
enabled novalidated ±íʾ²»¶ÔÊý¾Ý¿âÄÚµÄÊý¾Ý½øÐÐУÑé¶øÖ»ÊÇÒªÇóºóÀ´²åÈëµÄÊý¾ÝÂú×ãÔ¼ÊøÌõ¼þ¡£
SQL> select * from t2;
VID VNAME VSEX
---------- ---------- ----------
1 a y
2 b
3 c x
SQL> alter table t2 modify VSEX not null enable novalidate;
Table altered
SQL> select * from t2;
VID VNAME VSEX
---------- ---------- ----------
1 a y
2 b
3 c x
SQL> insert into t2 values ('4','d','');
insert into t2 values ('4','d','')
ORA-01400: ÎÞ·¨½« NULL ²åÈë ("PORTALDB"."T2"."VSEX")
SQL>
SQL> select t.constraint_name, t.status, t.validated from user_constraints t;
CONSTRAINT_NAME STATUS VALIDATED
------------------------------ -------- -------------
SYS_C003765 ENABLED VALIDATED
PK_T ENABLED VALIDATED
SYS_C003768 ENABLED NOT VALIDATED
¶ÔÓÚΨһԼÊøºÍÖ÷¼üÔ¼ÊøÓÉÓÚÔÚ´´½¨Ê±ºòÒª´´½¨Î¨Ò»Ë÷Òý£¬ËùÒÔÔÚÆÕͨ±íÖÐÈç¹û±íÖÐÊý¾ÝÓÐÎ¥·´Ô¼Êøµ
Ïà¹ØÎĵµ£º
Ò»¡¢ÔÚUnixÏ´´½¨Êý¾Ý¿â
1.È·¶¨Êý¾Ý¿âÃû¡¢Êý¾Ý¿âʵÀýÃûºÍ·þÎñÃû
¹ØÓÚÊý¾Ý¿âÃû¡¢Êý¾Ý¿âʵÀýÃûºÍ·þÎñÃû£¬ÎÒ֮ǰÓÐרÃÅÓÃһƪÀ´Ïêϸ½éÉÜ¡£ÕâÀï¾Í²»ÔÙ˵Ã÷ÁË¡£
2.´´½¨²ÎÊýÎļþ
²ÎÊýÎļþºÜÈ·¶¨ÁËÊý¾Ý¿âµÄ×ÜÌå½á¹¹¡£Oracle10gÓÐÁ½ÖÖ²ÎÊýÎļþ£¬Ò»¸öÊÇÎı¾²ÎÊýÎļþ£¬Ò»ÖÖÊÇ·þÎñÆ÷²ÎÊýÎļþ¡£ÔÚ´´½¨Ê ......
ÔÚLinuxÉÏ°²×°oracleµÄʱºò²»Ð¡ÐÄ°²×°ÁËÁ½´Îlistener, ¸ãµÃlistenerµÄ¶Ë¿ÚºÅ±ä³ÉÁË1522¶ø²»ÊÇȱʡµÄ1521, ¿Í»§¶ËÁ¬Á˺þö¼Ã»ÓÐÁ¬½ÓÉÏ£¬×îºó²Å·¢ÏÖÊÇlistenerµÄ¶Ë¿ÚºÅ²»¶Ô¡£Ò»ÏÂÊÇÎҸıälistener¶Ë¿ÚºÅµÄ²½Ö裺
1. Ê×ÏÈÐèҪֹͣlistener, ʹÓÃÃüÁîlsnrctl stop
2. listenerÍ£Ö¹ÒԺ󣬵½ÄãµÄ$ORACLE_HOME/network/adminÏÂÕ ......
µÈ´ýʼþµÄÔ´Æð
µÈ´ýʼþµÄ¸ÅÄî´ó¸ÅÊÇ´ÓORACLE 7.0.12ÖÐÒýÈëµÄ£¬´óÖÂÓÐ100¸öµÈ´ýʼþ¡£ÔÚORACLE 8.0ÖÐÕâ¸öÊýÄ¿Ôö´óµ½ÁË´óÔ¼150¸ö£¬ÔÚORACLE 8IÖдóÔ¼ÓÐ220¸öʼþ£¬ÔÚORACLE 9IR2ÖдóÔ¼ÓÐ400¸öµÈ´ýʼþ£¬¶øÔÚ×î½üORACLE 10GR2ÖУ¬´óÔ¼ÓÐ874¸öµÈ´ýʼþ¡£
ËäÈ»²»Í¬°æ±¾ºÍ×é¼þ°²×°¿ÉÄÜ»áÓв»Í¬ÊýÄ¿µÄµÈ´ýʼþ£¬µ«ÊÇÕâЩµÈ´ýÊ ......
ORACLEÖÐÊý¾Ý×ÖµäÊÓͼ·ÖΪ3´óÀà, ÓÃǰ׺Çø±ð£¬·Ö±ðΪ£ºUSER£¬ALL ºÍ DBA£¬Ðí¶àÊý¾Ý×ÖµäÊÓͼ°üº¬ÏàËƵÄÐÅÏ¢¡£
USER_*:ÓйØÓû§ËùÓµÓеĶÔÏóÐÅÏ¢£¬¼´Óû§×Ô¼º´´½¨µÄ¶ÔÏóÐÅÏ¢
ALL_*£ºÓйØÓû§¿ÉÒÔ·ÃÎʵĶÔÏóµÄÐÅÏ¢£¬¼´Óû§×Ô¼º´´½¨µÄ¶ÔÏóµÄÐÅÏ¢¼ÓÉÏÆäËûÓû§´´½¨µÄ¶ÔÏ󵫸ÃÓû§ÓÐȨ·ÃÎʵÄÐÅÏ¢
DBA_* ......