Create, modify, and delete mysql triggers.
// Make a simple exercise. When creating a simple trigger to add an article, the time is automatically added. By default, the author is 'memories of the records'
Show columns from test; // view the table structure
// View the existing trigger
Show triggers \ G
// Replace the ending character with $
\ D $
// Create a trigger, use before to insert the trigger (also apply to update), and apply it to each row of the test table, with the unix Timestamp
Create trigger insert_arc before insert on test
For each row
Begin
If new. nickname is null then
Set new. nickname = 'memories of the records ';
End if;
If new. addtime is null then
Set new. addtime = unix_timestamp ();
End if;
End
$
// Insert Test Data
Insert into test () values () $
// Select * from test $
// Perform a simple exercise. When creating a simple trigger to add an article, the time is automatically added. By default, the author sets the 'note In the records' show columns from test; // view the table structure // view the existing trigger show triggers \ G // Replace the Terminator with $ \ d $ // create a trigger, use before to insert a trigger (also for update) and apply it to each row in the test table, time unix timestamp create trigger insert_arc before insert on testfor each rowbegin if new. nickname is null then set new. nickname = 'memory of the records'; end if; if new. addtime is null then set new. addtime = unix_timestamp (); end if; end $ // Insert test data insert into test () values () $ // select * from test $ complete !!!