Introduction to Database Triggers with PostgreSQL

Introduction to Database Triggers with PostgreSQL

Introduction to Database Triggers with PostgreSQL

Automate Database Tasks Using Triggers

Language: english

Note: 0/5 (0 notes) 264 students  New course 

Instructor(s): Bluelime Learning Solutions

Last update: 2022-11-02

What you’ll learn

  • Install PostgreSQL on Windows
  • Install PostgreSQL on Macs
  • Installing PgAdmin on Macs
  • Connect to PostgreSQL with PgAdmin
  • Restore a sample database
  • Create a new table
  • Populate a table
  • Creating a trigger
  • Manage Triggers

 

Requirements

  • Basic knowledge of database concepts advised.

 

Description

A database trigger is procedural code that is automatically executed in response to certain events on a particular table or view in a database. The trigger is mostly used for maintaining the integrity of the information on the database. For example, when a new record (representing a new worker) is added to the employees table, new records should also be created in the tables of the taxes, vacations and salaries. Triggers can also be used to log historical data, for example to keep track of employees’ previous salaries.

A PostgreSQL trigger is a function invoked automatically whenever an event associated with a table occurs. An event could be any of the following: INSERT, UPDATE, DELETE or TRUNCATE.

A trigger is a special user-defined function that binds to a table. To create a new trigger, you must define a trigger function first, and then bind this trigger function to a table. The difference between a trigger and a user-defined function is that a trigger is automatically invoked when an event occurs.

PostgreSQL provides two main types of triggers: row and statement level triggers. The differences between the two are how many times the trigger is invoked and at what time. For example, if you issue an UPDATE statement that affects 20 rows, the row level trigger will be invoked 20 times, while the statement level trigger will be invoked 1 time.

You can specify whether the trigger is invoked before or after an event. If the trigger is invoked before an event, it can skip the operation for the current row or even change the row being updated or inserted. In case the trigger is invoked after the event, all changes are available to the trigger.  

 

Who this course is for

  • Beginners to creating Triggers

 

Course content

  • PostgreSQL Setup
    • Introduction
    • What is PostgreSQL
    • Installing PostgreSQL on Windows
    • Installing PostgreSQL on Macs
    • Installing PgAdmin on Macs
    • Connecting to PostgreSQL with PgAdmin
    • Restore a sample database
    • Create a new table
    • Populate a table
    • Query Table
  • Database Triggers
    • What are Triggers
    • Creating your first trigger : Part 1
    • Creating your first trigger : Part 2
    • Creating your first trigger : Part 3
    • Managing Triggers

 

 

Don’t miss any coupons by joining our Telegram group 

Udemy Coupon Code 100% off | Udemy Free Course | Udemy offer | Course with certificate