DB2: Triggers Cheat Sheet

Creating a BEFORE trigger

db2 create sequence <seq_name> 

Retrieving values from table

db2 select * from <tablename>

Creating an AFTER trigger

db2 create trigger <trigger_name> no cascade before insert on 
<table_name> referencing new as <table_object> for each row set
 <table_object>.<col_name>=nextval for <sequence_name> 

Dropping a trigger

db2 drop trigger <trigger_name> 

Leave a Reply

Your email address will not be published. Required fields are marked *