What is a trigger and why do we need triggers in a database?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shailendramishr

    #1

    What is a trigger and why do we need triggers in a database?

    I want to learn how to run trigger into data base. so first i want to know what is trigger and what is it's need.
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    A trigger is an action that can be set to run when an event occur.

    An example of a use for a trigger would be to update an inventory table. Suppose you have a database that stores customers, orders, and inventory. When a customer makes an order to purchase an item you will want to update the inventory table to reflect the change in stock for that item. This is where you would call a trigger.

    For more information on creating triggers and their syntax please look at the following links.
    Creating MySQL Triggers
    and
    Using MySQL Triggers

    Comment

    Working...