oracle constraints(1)
oracle µÄÔ¼ÊøÖ÷ÒªÊÇÔÚÒµÎñÂß¼²ãÃæά»¤Êý¾ÝµÄÍêÕûÐÔ¡£Ö÷Ҫͨ¹ý³ÌÐòÔ±ÔÚÓ¦ÓóÌÐòÖй涨ԼÊø»òÕßͨ¹ý¶¨Òå´¥·¢Æ÷À´Î¬»¤Êý¾ÝÍêÕûÐÔ£¬×îºóÊÇͨ¹ýʹÓÃoracle×Ô´øµÄÔ¼ÊøÀ´Î¬»¤Êý¾ÝÍêÕûÐÔ¡£ÄÜʹÓÃoracle×Ô´øµÄÔ¼Êø´ïµ½ÒªÇó¾Í¾¡Á¿Ê¹ÓÃoracle×Ô´øµÄÔ¼Êø£¬ÒòΪʹÓô¥·¢Æ÷µÈÓû§×Ô¶¨ÒåÔ¼Êø¶¼»áÓ°ÏìÊý¾Ý¿âµÄÐÔÄÜ¡£ÀýÈ磺ʹÓô¥·¢Æ÷ʱ»á¶Ô±í½øÐÐËø¶¨²¢½øÐбíɨÃè»òÕßË÷ÒýɨÃ裬ÕâЩ¶¼»á½µµÍÊý¾Ý¿âÐÔÄܺͲ¢·¢ÐÔ¡£
oracle Ô¼ÊøÖ÷Òª·ÖΪÒÔϼ¸ÖÖ£º
not null ·Ç¿ÕÔ¼Êø, unique ΨһԼÊø, primary key Ö÷¼üÔ¼Êø, foreign key Íâ¼üÔ¼Êø, check Ô¼Êø¡£
not null ·Ç¿ÕÔ¼Êø£º
´´½¨·½Ê½£º1, ½¨±íʱÔÚÁ춱ð¶¨Òå(Ò²¾ÍÊÇÖ»ÄÜÔÚ¶¨Òå±íʱ½«Ô¼ÊøµÄ¶¨ÒåдÔÚ¸ÃÁкóÃæ),2ÖÖ·½Ê½¡£Ò»ÖÖʹÓÃ×Ô¶¨ÒåÔ¼ÊøÃû³Æ£¬Ò»ÖÖÊÇʹÓÃϵͳĬÈÏÃû³Æ¡£
create table t
(
tid number(8) constraint NK_t1 not null,
tname varchar2(10) not null
)
SQL> select t.constraint_name, t.table_name, t.status, t.deferrable from user_constraints t;
CONSTRAINT_NAME TABLE_NAME STATUS DEFERRABLE
--------------- ------------------------------ -------- --------------
NK_T1 T ENABLED NOT DEFERRABLE
SYS_C003735 T ENABLED NOT DEFERRABLE
SQL>
2£¬ÔÚ±í½¨Á¢ºó¶Ô±í½øÐÐÐ޸ģ¬µ«ÊÇҪȷ±£±íÖÐÊý¾ÝûÓÐÎ¥·´Ô¼Êø¡£
SQL> alter table t modify tid not null;
Table altered
SQL> select t.constraint_name, t.table_name, t.status, t.deferrable from user_constraints t;
CONSTRAINT_NAME TABLE_NAME STATUS DEFERRABLE
--------------- ------------------------------ -------- --------------
SYS_C003736 T ENABLED NOT DEFERRABLE
SQL>
check Ô¼Êø
´´½¨·½Ê½£º¿ÉÒÔÔÚ±í¼¶±ðºÍÁ춱ð½øÐж¨Òå(¼È¿ÉÒÔÔÚÁкóÃ涨ÒåÒ²¿ÉÒÔÔÚÁж¨ÒåÍêºóÔÙ¶¨Òå)¡£Ò²ÊÇ2ÖÖ¶¨Ò巽ʽ¡£
SQL> create table t
2 (
3 tid number(8) ,
4 tname varchar2(10),
5 constraint CK_T1 check ((tid is not null) and (tid > 0))
Ïà¹ØÎĵµ£º
ËäȻѧϰJavaºÜ¾ÃÁË£¬×Ô¼ºÒ²Á¬½Ó¹ýһЩÊý¾Ý¿â£¬±ÈÈçmysqlÖ®ÀàµÄ£¬Èç½ñÄØ£¬Ò²Ñ§Ï°ÁËÒ»¶Îʱ¼äµÄOracle£¬È»¶øÄØ£¬½ñÌìÊÇÎÒµÚÒ»´ÎÁ¬½ÓOracle£¬ºÙºÙ£¬Ó¦¸Ã»¹²»ËãÌ«³Ù°É¡£
½ñÌìÄØ£¬Óе㱿׾£¬´ó¼ÒĪЦ£¡
ÎÒÕâÊÇÒ»¸ö²éѯÀý×Ó
Ê×ÏÈ£¬Ô ......
½«±í¿Õ¼äºÍÊý¾ÝÎļþ´ÓÒ»¸öλÖÃÒƶ¯µ½ÁíÒ»¸öλÖõIJÙ×÷·½·¨
Ò»£® OFFLINE
OFFLINE ·ÖΪALTER DATABASE Óë ALTER TABLESPACE OFFLINE£¬
ËûÃǵÄÇø±ð²Î¿´blog£ºhttp://blog.csdn.net/tianlesoftware/archive/2009/11/29/4898800.aspx
°´Êý¾ÝÎļþÀ´£º
1.ÏȽ«ÏàÓ¦µÄÊý¾ÝÎļþ offl ......
2008Äê06ÔÂ01ÈÕ ÐÇÆÚÈÕ 14:52
OracleµÄÊý¾Ý¿â¶ÔÏó·ÖΪÎåÖÖ£º±í£¬ÊÓͼ£¬ÐòÁУ¬Ë÷ÒýºÍͬÒå´Ê¡£
ÊÓͼÊÇ»ùÓÚÒ»¸ö±í»ò¶à¸ö±í»òÊÓͼµÄÂß¼±í£¬±¾Éí²»°üº¬Êý¾Ý£¬Í¨¹ýËü¿ÉÒÔ¶Ô±íÀïÃæµÄÊý¾Ý½øÐвéѯºÍÐ޸ġ£ÊÓͼ»ùÓڵıí³ÆΪ»ù±í¡£
ÊÓͼÊÇ´æ´¢ÔÚÊý¾Ý×ÖµäÀïµÄÒ»ÌõselectÓï¾ä¡£ ͨ¹ý´´½¨ÊÓͼ¿ÉÒÔÌáÈ¡Êý¾ÝµÄÂß¼Éϵļ¯ ......
oracleµÄÌåϵ̫ÅÓ´óÁË£¬¶ÔÓÚ³õѧÕßÀ´Ëµ£¬ÄÑÃâ»áÓÐЩÎÞ´ÓÏÂÊֵĸоõ£¬Ê²Ã´¶¼Ïëѧ£¬½á¹ûʲô¶¼Ñ§²»ºÃ£¬ËùÒÔ°Ñѧϰ¾Ñé¹²Ïíһϣ¬Ï£ÍûÈøոÕÈëÃŵÄÈ˶ÔoracleÓÐÒ»¸ö×ÜÌåµÄÈÏʶ£¬ÉÙ×ßһЩÍä·¡£
Ò»¡¢¶¨Î»
oracle·ÖÁ½´ó¿é£¬Ò»¿éÊÇ¿ª·¢£¬Ò»¿éÊǹÜÀí¡£¿ª·¢Ö÷ÒªÊÇдд´æ´¢¹ý³Ì¡¢´¥·¢Æ÷ʲôµÄ£¬»¹ÓоÍÊÇÓÃOracle ......