oracle constraints(3)
oracle constraints Ó¦ÓÃ
oracle constraints¿ÉÒÔÉèÖÃΪÁ¢¼´¼ì²é»òÕßµ±Ê±ÊÂÎñÌύʱ¼ì²é¡£
¿ÉÒÔÔÚ´´½¨Ô¼ÊøµÄʱºòÖ¸¶¨ÊÇdeferrable¡£È»ºóͨ¹ýset constraints xxx set deferred»òÕßimmediate,Ò²¿ÉÒÔÔÚseesion¼¶±ðÉ趨ËùÓÐÔ¼ÊøΪdeferred»òÕßimmediate(alter seesion set constraints deferred/immediate)¡£
SQL> select t.constraint_name, t.status, t.validated, t.deferrable from user_constraints t;
CONSTRAINT_NAME STATUS VALIDATED DEFERRABLE
------------------------------ -------- ------------- --------------
SYS_C003765 ENABLED VALIDATED NOT DEFERRABLE
SYS_C003768 ENABLED NOT VALIDATED NOT DEFERRABLE
UK_T ENABLED NOT VALIDATED NOT DEFERRABLE
SQL> alter table t2 add primary key(vid) deferrable;
Table altered
SQL>
SQL> select t.constraint_name, t.status, t.validated, t.deferrable from user_constraints t;
CONSTRAINT_NAME STATUS VALIDATED DEFERRABLE
------------------------------ -------- ------------- --------------
SYS_C003765 ENABLED VALIDATED NOT DEFERRABLE
SYS_C003772 ENABLED VALIDATED DEFERRABLE
SYS_C003768 ENABLED NOT VALIDATED NOT DEFERRABLE
UK_T ENABLED NOT VALIDATED NOT DEFERRABLE
SQL> select * from t2;
VID VNAME VSEX
---------- ---------- ----------
1 a y
2 b
3 c x
SQL> insert into t2 values (1,'d','y');
insert into t2 values (1,'d','y')
ORA-00001: Î¥·´Î¨Ò»Ô¼ÊøÌõ¼þ (PORTALDB.SYS_C003772)
SQL> set constraints SYS_C003772 deferred;
Constraints set
SQL> insert into t2 values (1,'d','y');
1 row inserted
SQL> set constraints SYS_C003772 deferred;
Constraints set
SQL> commit;
commit
ORA-02091: ÊÂÎñ´¦ÀíÒÑÖØËã
ORA-00001: Î¥·´Î¨Ò»Ô¼ÊøÌõ¼þ (PORTALDB
Ïà¹ØÎĵµ£º
ËäȻѧϰJavaºÜ¾ÃÁË£¬×Ô¼ºÒ²Á¬½Ó¹ýһЩÊý¾Ý¿â£¬±ÈÈçmysqlÖ®ÀàµÄ£¬Èç½ñÄØ£¬Ò²Ñ§Ï°ÁËÒ»¶Îʱ¼äµÄOracle£¬È»¶øÄØ£¬½ñÌìÊÇÎÒµÚÒ»´ÎÁ¬½ÓOracle£¬ºÙºÙ£¬Ó¦¸Ã»¹²»ËãÌ«³Ù°É¡£
½ñÌìÄØ£¬Óе㱿׾£¬´ó¼ÒĪЦ£¡
ÎÒÕâÊÇÒ»¸ö²éѯÀý×Ó
Ê×ÏÈ£¬Ô ......
1.OracleDBConsoleorcl oem¿ØÖÆ̨µÄ·þÎñ½ø³Ì
2.OracleJobSchedulerORCL ¶¨Ê±Æ÷µÄ·þÎñ½ø³Ì
3.OracleOraDb10g_home1iSQL*Plus isql*plusµÄ·þÎñ½ø³Ì
4.OracleOraDb10g_home1TNSListener ¼àÌýÆ÷µÄ·þÎñ½ø³Ì
5.Or ......
ORACLEÖÐÊý¾Ý×ÖµäÊÓͼ·ÖΪ3´óÀà, ÓÃǰ׺Çø±ð£¬·Ö±ðΪ£ºUSER£¬ALL ºÍ DBA£¬Ðí¶àÊý¾Ý×ÖµäÊÓͼ°üº¬ÏàËƵÄÐÅÏ¢¡£
USER_*:ÓйØÓû§ËùÓµÓеĶÔÏóÐÅÏ¢£¬¼´Óû§×Ô¼º´´½¨µÄ¶ÔÏóÐÅÏ¢
ALL_*£ºÓйØÓû§¿ÉÒÔ·ÃÎʵĶÔÏóµÄÐÅÏ¢£¬¼´Óû§×Ô¼º´´½¨µÄ¶ÔÏóµÄÐÅÏ¢¼ÓÉÏÆäËûÓû§´´½¨µÄ¶ÔÏ󵫸ÃÓû§ÓÐȨ·ÃÎʵÄÐÅÏ¢
DBA_* ......
²éѯÓû§ÐÅÏ¢
SELECT USERNAME,DEFAULT_TABLESPACE, TEMPORARY_TABLESPACE, PROFILE, ACCOUNT_STATUS, CREATED from dba_users; ²éѯÓû§¿Õ¼äʹÓúÍÉÏÏÞÇé¿ö
SELECT username, tablespace_name, bytes/1024/1024 space_used_in_mb, max_bytes/1024/1024 max_space_in_mb from dba_ts_quotas; ´´½¨ ......