³õʶSQLSERVER´¥·¢Æ÷(Ò»)
´¥·¢Æ÷ÊÇÒ»ÖÖÌØÊâµÄ´æ´¢¹ý³Ì£¬ÀàËÆÓÚÆäËü±à³ÌÓïÑÔÖеÄʼþº¯Êý£¬SQL Server? ÔÊÐíΪ INSERT¡¢UPDATE¡¢DELETE ´´½¨´¥·¢Æ÷£¬µ±ÔÚ±í£¨ÊÓͼ£©ÖвåÈë¡¢¸üС¢É¾³ý¼Ç¼ʱ£¬´¥·¢Ò»¸ö»òһϵÁÐ T-SQL Óï¾ä¡£
±¾×¨ÌâµÄÄ¿µÄ²¢·ÇÊÇÏòÄúÏ꾡µØ½éÉÜ´¥·¢Æ÷£¬¶øÊÇϵͳµØÏòÄú½éÉÜ´¥·¢Æ÷µÄ³£ÓÃ֪ʶÓëÏà¹ØÓ¦Ó㬲¢ÓëÄúÒ»Æð̽ÌÖÓ¦ÓþÑ飬Èç¹ûÄúÐèÒªÁ˽ⴥ·¢Æ÷²»³£ÓõÄ֪ʶµã£¬Çë²Î¼û SQL Server? Áª»ú´ÔÊ飨°²×° SQL Server? ʱĬÈÏÊÇ°²×°µÄ£©¡£
a.»ù´¡£´´½¨Ò»¸ö¼òµ¥µÄ´¥·¢Æ÷
´¥·¢Æ÷ÊÇÒ»ÖÖÌØÊâµÄ´æ´¢¹ý³Ì£¬ÀàËÆÓÚʼþº¯Êý£¬SQL Server? ÔÊÐíΪ INSERT¡¢UPDATE¡¢DELETE ´´½¨´¥·¢Æ÷£¬¼´µ±ÔÚ±íÖвåÈë¡¢¸üС¢É¾³ý¼Ç¼ʱ£¬´¥·¢Ò»¸ö»òһϵÁÐ T-SQLÓï¾ä¡£
´¥·¢Æ÷¿ÉÒÔÔÚ²éѯ·ÖÎöÆ÷Àï´´½¨£¬Ò²¿ÉÒÔÔÚ±íÃûÉϵãÓÒ¼ü->“ËùÓÐÈÎÎñ”->“¹ÜÀí´¥·¢Æ÷”À´´´½¨£¬²»¹ý¶¼ÊÇҪд T-SQL Óï¾äµÄ£¬Ö»ÊÇÔÚ²éѯ·ÖÎöÆ÷ÀïÒªÏÈÈ·¶¨µ±Ç°²Ù×÷µÄÊý¾Ý¿â¡£
´´½¨´¥·¢Æ÷Óà CREATE TRIGGER
CREATE TRIGGER ´¥·¢Æ÷Ãû³Æ
ON ±íÃû
FOR INSERT¡¢UPDATE »ò DELETE
AS
T-SQL Óï¾ä
×¢Ò⣺´¥·¢Æ÷Ãû³ÆÊDz»¼ÓÒýºÅµÄ¡£
ÈçÏÂÊÇÁª»ú´ÔÊéÉϵÄÒ»¸öʾÀý£¬µ±ÔÚ titles ±íÉϸü¸Ä¼Ç¼ʱ£¬·¢ËÍÓʼþ֪ͨ MaryM¡£
CREATE TRIGGER reminder
ON titles
FOR INSERT, UPDATE, DELETE
AS
EXEC master..xp_sendmail 'MaryM',
'Don''t forget to print a report for the distributors.'
b.»ù´¡-ɾ³ý´¥·¢Æ÷
Óòéѯ·ÖÎöÆ÷ɾ³ý
ÔÚ²éѯ·ÖÎöÆ÷ÖÐʹÓà drop trigger ´¥·¢Æ÷Ãû³Æ À´É¾³ý´¥·¢Æ÷¡£
Ò²¿ÉÒÔͬʱɾ³ý¶à¸ö´¥·¢Æ÷£ºdrop trigger ´¥·¢Æ÷Ãû³Æ,´¥·¢Æ÷Ãû³Æ...
×¢Ò⣺´¥·¢Æ÷Ãû³ÆÊDz»¼ÓÒýºÅµÄ¡£ÔÚɾ³ý´¥·¢Æ÷֮ǰ¿ÉÒÔÏÈ¿´Ò»Ï´¥·¢Æ÷ÊÇ·ñ´æÔÚ£º
if Exists(select name from sysobjects where name=´¥·¢Æ÷Ãû³Æ and xtype='TR')
ÓÃÆóÒµ¹ÜÀíÆ÷ɾ³ý
ÔÚÆóÒµ¹ÜÀíÆ÷ÖУ¬ÔÚ±íÉϵãÓÒ¼ü->“ËùÓÐÈÎÎñ”->“¹ÜÀí´¥·¢Æ÷”£¬Ñ¡ÖÐËùҪɾ³ýµÄ´¥·¢Æ÷£¬È»ºóµã»÷“ɾ³ý”¡£
c.»ù´¡-ÖØÃüÃû´¥·¢Æ÷
Ïà¹ØÎĵµ£º
Ïà¹ØÎÄÕÂ:
mysqlÊý¾Ý¿âËø
ORACLEÀXÖÖËøģʽ
ÍƼöȦ×Ó: Pipboy
¸ü¶àÏà¹ØÍƼö
new Draggable("related_topics");
¶ÔËø»úÖƵÄÑо¿Òª¾ß±¸Á½¸öÌõ¼þ£º
1£®Êý¾ÝÁ¿´ó
2£®¶à¸öÓû§Í¬Ê±²¢·¢
Èç¹ûȱÉÙÕâÁ½¸öÌõ¼þ£¬Êý¾Ý¿â²»ÈÝÒײúÉúËÀËøÎÊÌâ¡£Ñо¿ÆðÀ´¿ÉÄÜ»áʱ¶¹ ......
Ò»¡¢Êý¾Ý¿â½á¹¹µÄÉè¼Æ
Èç¹û²»ÄÜÉè¼ÆÒ»¸öºÏÀíµÄÊý¾Ý¿âÄ£ÐÍ£¬²»½ö»áÔö¼Ó¿Í»§¶ËºÍ·þÎñÆ÷¶Î³ÌÐòµÄ±à³ÌºÍά»¤µÄÄѶȣ¬¶øÇÒ½«»áÓ°Ïìϵͳʵ¼ÊÔËÐеÄÐÔÄÜ¡£ËùÒÔ£¬ÔÚÒ»¸öϵͳ¿ªÊ¼ÊµÊ©Ö®Ç°£¬Í걸µÄÊý¾Ý¿âÄ£Ð͵ÄÉè¼ÆÊDZØÐëµÄ¡£
ÔÚÒ»¸öϵͳ·ÖÎö¡¢Éè¼Æ½×¶Î£¬ÒòΪÊý¾ÝÁ¿½ÏС£¬¸ººÉ½ÏµÍ¡£ÎÒÃÇÍùÍù ......
if exists (select * from dbo.sysobjects where name='SplitStr' )
drop FUNCTION SplitStr
go
CREATE FUNCTION SplitStr (@splitString varchar(8000), @separate varchar(10))
RETURNS @returnTable ......
´¥·¢Æ÷µÄ´´½¨¼°Ê¹ÓÃ(sqlserver 2005)
´´½¨ DML »ò DDL ´¥·¢Æ÷¡£´¥·¢Æ÷ÊÇÊý¾Ý¿â·þÎñÆ÷Öз¢Éúʼþʱ×Ô¶¯Ö´ÐеÄÌØÖÖ´æ´¢¹ý³Ì¡£Èç¹ûÓû§ÒªÍ¨¹ýÊý¾Ý²Ù×÷ÓïÑÔ (DML) ʼþ±à¼Êý¾Ý£¬ÔòÖ´ÐÐ DML ´¥·¢Æ÷¡£DML ʼþÊÇÕë¶Ô±í»òÊÓͼµÄ INSERT¡¢UPDATE »ò DELETE Óï¾ä¡£DDL ´¥·¢Æ÷ÓÃÓÚÏìÓ¦¸÷ÖÖÊý¾Ý¶¨ÒåÓïÑÔ (DDL) ʼþ¡£ÕâЩÖ÷ÒªÊÇ CRE ......