SQLÀïµÄÖ÷¼üºÍÍâ¼ü
Õâ¸öÂß¼¹Øϵէ¿´ÆðÀ´±È½Ï¸´ÔÓ£¬ÅªÇå³þÁ˾ͺã¡
ÓÐÁ½¸ö±í£¬
student(
id,
name,
primary key (id)
);
studentInfo(
id,
age,
address,
foreign key(id) references outTable(id) on delete cascade on update cascade
);
µ±ÎÒÃÇɾ³ýstudent±íµÄʱºò×ÔȻϣÍûstudentInfoÀïµÄÏà¹ØÐÅÏ¢Ò²±»É¾³ý£¬Õâ¾ÍÊÇÍâ¼üÆð×÷Óõĵط½¡£
Íâ¼üÓÐÒ»¸öÔÔò£¬¾ÍÊÇÒ»¸ö±íµÄÍâ¼ü±ØÐëÊÇÁíÒ»¸ö±íµÄÖ÷¼ü,ÈçstudentInfo±íµÄÍâ¼üÊÇid,ÊÇstudent±íµÄÖ÷¼ü¡£Ç°ÕßÊÇ´Ó±í£¬ºóÕßÊÇÖ÷±í£¬ÈçstudentInfoÊÇ´Ó±í£¬studentÊÇÖ÷±í¡£
foreign key(id) references outTable(id) on delete cascade on update cascade£¬Õâ¾ä»°µÄÒâ˼ÊÇ£¬ÉèÖÃstudent±íµÄidΪstudentInfo±íµÄÍâ¼ü£¬student±íÀïµÄÐÅÏ¢ÓÐÈκεÄdelete»òÕßupdateµÄʱºò£¬studentInfoÀïµÄÐÅÏ¢Ò²ÒªËæÖ®¸Ä±ä¡£
Ïà¹ØÎĵµ£º
¸ÅÊö
Microsoft SQL Server 2008 ÈÃÄúÄܹ»Í¨¹ýÖ±¹ÛµÄÊý¾ÝÍÚ¾òµÄÔ¤²âÐÔ·ÖÎöÀ´×ö³öÃ÷ÖǺÏÀíµÄ¾ö²ß£¬ÎÞ·ìµØÕûºÏ Microsoft ÉÌÒµÖÇÄÜƽ̨²¢¿ÉÀ©Õ¹ÖÁÉÌÒµÓ¦ÓóÌÐò¡£
ÖØ´óµÄй¦ÄÜ
ͬʱÀûÓôíÎóºÍ¾«È·¶ÈµÄͳ¼Æ·ÖÊýÀ´²âÊÔ¶à¸öÊý¾ÝÍÚ¾òÄ£ÐÍ£¬²¢ÀûÓý»²æÑéÖ¤À´È·ÈÏÆäÎȶ¨ÐÔ
ÔÚµ¥Ò»½á¹¹Öн¨Á¢¶à¸ö²»¼æÈݵÄÍÚ¾òÄ£ÐÍ¡¢ÔÚɸѡ¹ýµÄÊ ......
--------------------------------------------------------------------------
-- Author : ÔÖø£º²»Ïê ¸Ä±à£ºhtl258(Tony)
-- Subject: ÍêÉÆSQLÅ©Àúת»»º¯Êý£¨ÏÔʾÖÐÎĸñʽ£¬¼ÓÈëÈóÔµÄÏÔʾ£©
-------------------------------------------------------------------------- ......
дSQLµÄ±Èд.NET³ÌÐòµÄÌåÑéÉϲîÒ»µÈ£¬Ã»ÓÐÖÇÄÜÌáʾ£¬ÐèÒª¼Çס¹Ø¼ü×Ö£¬º¯Êý»òÕß²»¶ÏµØCopy±í×Ö¶ÎÃû£¬×Ô¶¨Ò庯Êý£¬´æ´¢¹ý³ÌÖ®ÀàµÄ¡£²»¹ýÔÚ
VS2010ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃÖÇÄÜÌáʾÁË£¬ÈçÏÂÃ漸·ùͼËùʾ£º
ÔÚ±à¼Æ÷ÖУ¬ ÊäÈë Shift + J
£¨Ìáʾ£º VS2010 ¿ª·¢¹¤¾ßÖбêµÄÊÇ Ctrl +J ÆäʵӦ¸ÃÊÇ Shift + J £©¾Í¿ÉÒÔ×Ô¶¯´ò¿ªÕâ¸öÖÇ ......