Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 32 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
32
Dung lượng
462,5 KB
Nội dung
Session 5Introducing to Triggers
ReviewIn preview session, we learnt:Stored ProceduresDefine Stored ProceduresTypes of Stored ProceduresCreate and Execute Stored ProceduresViewing InformationModifying and Dropping Stored ProceduresWorking with Stored Procedures
Session objectivesIntroduce to TriggersCreate DML TriggersWorking with DML TriggersModifying definitions of DML triggers
Introduce to TriggersIs stored procedure that is executed when modify data in tableIs defined on the INSERT, UPDATE, DELETE action on a tableUse of triggers:
Sample triggerAllenBrianCathyDerekGregMarkCarlKathyDerek
Sample triggerAllenBrianCathyDerekGregMarkCarlKathyTrigger FiredDerekInserted
Types of TriggersTrigger in SQL Server 2005 can be classified:Data Manipulation Language (DML) TriggersData Definition Language (DDL) TriggersLogon Triggers
DML TriggersAre executed when DML events occur in tables or viewsDML Triggers are of three main types:INSERT triggerUPDATE triggerDELETE trigger
Introduction to Inserted and Deleted Tables•Insert table contains copies of records that are modified with the INSERT and UPDATE operations on the trigger table.•Deleted table contains copies of records that are modified with the DELETE and UPDATE operations on the trigger table
Create triggersCREATE TRIGGER statement uses to create trigger. Syntax:CREATE TRIGGER Trigger_nameON tableFOR [DELETE, INSERT, UPDATE][WITH ENCRYPTION]AS Sql_statements
123doc.vn