oracle²¢ÇÒÔõôд
oracleÖеÄÍâ¼üÔ¼ÊøÈ·±£Êý¾ÝÍêÕûÐÔ£¬Ëü½ç˵Á˱í¼äÁеĹØÁª¹Øϵ£¬È·±£×Ó±íÖеÄÖµÔÚ¸¸±íÖб£´æ¡£½¨ÉèÍâ¼üÔ¼ÊøµÄÓï¾äΪ£ºalter table child_table add constraint fk_name foreign key (column_name) references parent_table (column_name)¡£Óŵã°üÀ¨£ºÊý¾ÝÍêÕûÐÔ¡¢¼¶Áª²Ù×÷¡¢Êý¾ÝÒ»ÖÂÐÔºÍÐÔÄÜÓÅ»¯¡£Íâ¼üÔ¼ÊøÀàÐÍ°üÀ¨¼òÆӺ͸´ºÏÀàÐÍ¡£É¾³ýÍâ¼üÔ¼ÊøµÄÓï¾äΪ£ºalter table child_table dro
Oracle ÖеÄÍâ¼üÔ¼Êø
Íâ¼üÔ¼ÊøÊÇÊý¾Ý¿âÖÐÓÃÀ´È·±£Êý¾ÝµÄÍêÕûÐÔºÍÒ»ÖÂÐÔµÄÒ»ÖÖÔ¼Êø¡£Ëü½ç˵ÁËÒ»ÕűíÖеÄÁÐÓëÁíÒ»ÕűíÖеÄÁÐÖ®¼äµÄ¹Øϵ£¬È·±£Ç°ÕßÖеÄÖµÔÚºóÕßÖб£´æ¡£
ÔõÑùÔÚ Oracle Öн¨ÉèÍâ¼üÔ¼Êø
ÔÚ Oracle ÖУ¬¿ÉÒÔʹÓÃÒÔÏÂÓï¾ä½¨ÉèÍâ¼üÔ¼Êø£º
ALTER TABLE child_table ADD CONSTRAINT fk_name FOREIGN KEY (column_name) REFERENCES parent_table (column_name);
µÇ¼ºó¸´ÖÆ
ÆäÖУº
child_table£º°üÀ¨Íâ¼üµÄ±í¡£
column_name£ºÍâ¼üÁеÄÃû³Æ¡£
parent_table£º±»ÒýÓÃµÄ±í¡£
fk_name£ºÔ¼ÊøµÄÃû³Æ£¨¿ÉÑ¡£©¡£
Íâ¼üÔ¼ÊøµÄÓŵã
Êý¾ÝÍêÕûÐÔ£º±ÜÃâÔÚ×Ó±íÖвåÈë»ò¸üв»±£´æÓÚ¸¸±íÖеÄÖµ¡£
¼¶Áª²Ù×÷£ºÔÊÐíÔÚ¸¸±íÖжԼͼ¾ÙÐиü¸Äʱ×Ô¶¯¶ÔÏà¹Ø×Ó±í¼Í¼¾ÙÐм¶Áª²Ù×÷£¨ÀýÈçɾ³ý»ò¸üУ©¡£
Êý¾ÝÒ»ÖÂÐÔ£ºÈ·±£×Ó±íÖеÄֵʼÖÕÓ븸±íÖеÄÖµÏàÆ¥Åä¡£
ÐÔÄÜÓÅ»¯£ºÍ¨¹ý½¨ÉèË÷ÒýÀ´¼ÓËÙ¸¸±íºÍ×Ó±íÖ®¼äµÄ²éÕÒ²Ù×÷¡£
Íâ¼üÔ¼ÊøµÄÀàÐÍ
Oracle ÖÐÓÐÁ½ÖÖÀàÐ͵ÄÍâ¼üÔ¼Êø£º
¼òÆÓµÄÍâ¼üÔ¼Êø£ºÖ»ÒýÓÃÒ»¸ö¸¸±íÖеÄÒ»¸öÁС£
¸´ºÏÍâ¼üÔ¼Êø£ºÒýÓöà¸ö¸¸±íÖеĶà¸öÁС£
ÔõÑùɾ³ýÍâ¼üÔ¼Êø
¿ÉÒÔʹÓÃÒÔÏÂÓï¾äɾ³ýÍâ¼üÔ¼Êø£º
ALTER TABLE child_table DROP CONSTRAINT fk_name;
µÇ¼ºó¸´ÖÆ
ÒÔÉϾÍÊÇoracle²¢ÇÒÔõôдµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡