FACTOID # 142: Americans consume the sixth-most spirits, the eighth-most beer and the 18th-most wine. They’re also likely to view heavy drinkers as undesirable neighbors.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

FACTS & STATISTICS    Simple view

  1. Select countries to view: (hold down Control key and click to select several)

     

     

    Compare:

     

     

  1. Select fact or statistic: (* = graphable)

     

     

     

  2. (OPTIONAL) Compare to statistic: (both need to be graphable)

     

     

     

  3. View result as:

     

       
(OR) SEARCH ALL encyclopedia, stats & forums:   

Encyclopedia > Database trigger

A database trigger is procedural code that is automatically executed in response to certain events on a particular table in a database. Triggers can restrict access to specific data, perform logging, or audit data modifications. The procedural code anti-pattern involves writing code by compiling all of the steps needed to accomplish a task in sequential order as opposed to abstracting the fundamental components of the task. ... In relational databases, SQL databases, and flat file databases, a table is a set of data elements (values) that is organized using a model of horizontal rows and vertical columns. ... This article is about computing. ...


There are two classes of triggers, they are either "row triggers" or "statement triggers". With row triggers you can define an action for every row of a table, while statement triggers occur only once per INSERT, UPDATE, or DELETE statement. Triggers cannot be used to audit data retrieval via SELECT statements. A SQL INSERT statement adds one or more records to a table in a relational database. ... An UPDATE statement in SQL changes data in one or more records in a relational database management system. ... An SQL DELETE statement removes one or more records from a table. ... An SQL SELECT statement returns a result set of records from one or more tables. ...


Each class can be of several types. There are "BEFORE triggers" and "AFTER triggers" which identifies the time of execution of the trigger. There is also an "INSTEAD OF trigger" which is a trigger that will execute instead of the triggering statement.


There are typically three triggering events that cause triggers to 'fire':

  • INSERT event (as a new record is being inserted into the database).
  • UPDATE event (as a record is being changed).
  • DELETE event (as a record is being deleted).

The trigger is used to automate DML condition process. A SQL INSERT statement adds one or more records to a table in a relational database. ... An UPDATE statement in SQL changes data in one or more records in a relational database management system. ... An SQL DELETE statement removes one or more records from a table. ... Data Manipulation Language (DML) is a family of computer languages used by computer programs or database users to retrieve, insert, delete and update data in a database. ...


The major features and effects of database triggers are that they:

  • do not accept parameters or arguments (but may store affected-data in temporary tables)
  • cannot perform commit or rollback operations because they are part of the triggering SQL statement (only through autonomous transactions)
  • can cause mutating table errors, if they are poorly written.

Contents

Triggers in Oracle

In addition to triggers that fire when data is modified, Oracle 9i supports triggers that fire when schema objects (that is, tables) are modified and when user logon or logoff events occur. These trigger types are referred to as "Schema-level triggers".


Schema-level triggers

  • After Creation
  • Before Alter
  • After Alter
  • Before Drop
  • After Drop
  • Before Logoff
  • After Logon

Triggers in Microsoft SQL Server

Microsoft SQL Server supports triggers either after or instead of an insert, update, or delete operation.


'Microsoft SQL Server supports triggers on tables and views with the constraint that a view can be referenced only by an INSTEAD OF trigger. In relational databases, SQL databases, and flat file databases, a table is a set of data elements (values) that is organized using a model of horizontal rows and vertical columns. ... In database theory, a view is a virtual or logical table composed of the result set of a query. ...


Microsoft SQL Server 2005 introduced support for Data Definition Language (DDL) triggers, which can fire in reaction to a very wide range of events, including: A Data Definition Language (DDL) is a computer language for defining data. ...

A full list is available on MSDN. A DROP statement in SQL removes an object from a relational database management system (RDBMS). ... A CREATE statement in SQL creates an object inside of a relational database management system (RDBMS). ... An ALTER statement in SQL changes the properties of an object inside of a relational database management system (RDBMS). ...


Performing conditional actions in triggers (or testing data following modification) is done through accessing the temporary Inserted and Deleted tables.


Visit MSDN for information on using Inserted and Deleted tables


Triggers in PostgreSQL

PostgreSQL introduced support for triggers in 1997. The following functionality in SQL:2003 is not implemented in PostgreSQL:

  • SQL allows triggers to fire on updates to specific columns; PostgreSQL does not support this feature.
  • The standard allows the execution of a number of other SQL statements than SELECT, INSERT, UPDATE, such as CREATE TABLE as the triggered action.

Triggers in MySQL

MySQL 5.0 introduced support for triggers. Some of the triggers MYSQL supports are

  • INSERT Trigger
  • UPDATE Trigger
  • DELETE Trigger

The SQL:2003 standard mandates that triggers give programmers access to record variables by means of a syntax such as REFERENCING NEW AS n. For example, if a trigger is monitoring for changes to a salary column one could write a trigger like the following:

 CREATE TRIGGER salary_trigger BEFORE UPDATE ON employee_table REFERENCING NEW ROW AS n, OLD ROW AS o FOR EACH ROW IF n.salary <> o.salary THEN --make desired changes; END IF; 

External links


  Results from FactBites:
 
Examiner's Resources- Trigger Pull Database (602 words)
As pressure is applied to the trigger, the gauge is watched and the amount of pressure required to release the sear is recorded.
Because it is a subject that comes up so often I thought it would be handy to make a database application that would allow me to search through the average trigger pull data of the firearms that have come in off the streets.
TRIGGER PULL DATA SEARCH is an application that allows for searches to be made for trigger pull data of specific firearms, models, calibers, and types.
7.6 Using Database Triggers (306 words)
A database trigger is a procedure that is automatically invoked by the DBMS in response to a change event against the database.
While database triggers are especially suited for auditing and statistical gathering, there is no need or no way to write a standard for limiting the scope of their use by application programmers.
The database trigger documentation should include the name of the trigger, the firing event or operation, the frequency of the firing, the name of the source table, the name of any table(s) affected by the trigger, a short description of the actions of the trigger.
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.