Today, I am sharing my experiences as a Python Engineer in SQL Automation, which I used in my previous job.
Previously, we have already covered the SQL Stored Procedures (database Functions), in case you have missed it:
• PostgreSQL Stored Procedures EXPLAINE...
Now, I want to take it a step further and use the real power of sequel, which is automating those procedures! Welcome to this hands-on tutorial where I explain complex concepts in easy language, step-by-step.
Here is a SQL playlist:
• Machine Learning in SQL? But I Am Pyt...
Machine Learning in SQL
• Machine Learning in SQL? But I Am Pyt...
========================================
Here is a timeline for your convenience:
01:13 SQL triggers VS. PostgreSQL triggers
01:47 Why Triggers & How to Create Them?
02:08 Hands-on tutorial starts here!
02:46 Step 1: creating trigger function (CREATE FUNCTION syntax)
03:46 Trigger Functions == SQL Beasts! (Local trigger function arguments)
04:22 Example of OLD, NEW variables inside trigger logic
05:01 Special "TG_" variable in PostgreSQL
05:48 Step 2: binding trigger function (CREATE TRIGGER syntax)
06:53 2 Trigger Levels (row-level & statement-level)
07:20 Get Ready for Real-Life Example
If you do not understand something, let me know in the comments section. I am always happy to hear from you and help if I can!
========================================
A couple of SQL snapshots from the tutorial:
-- A skeleton for creating trigger function:
CREATE FUNCTION trigger_function()
RETURNS TRIGGER
LANGUAGE PLPGSQL
AS $BODY$
BEGIN
-- trigger logic
END;
$BODY$
-- Syntax to create trigger:
-- provide the trigger name after the TRIGGER keywords
CREATE TRIGGER trigger_name
-- indicate the timing that causes the trigger to fire
{BEFORE | AFTER}
-- specify the event that invokes trigger: INSERT, DELETE, UPDATE, or TRUNCATE
{ event }
-- table name associated with the trigger, e.g., ON invoices
ON table_name
-- type of trigger (row-level trigger or statement-level trigger)
[FOR [EACH] { ROW | STATEMENT }]
-- name of trigger function
EXECUTE PROCEDURE trigger_function
========================================
Ways to connect:
Subscribe!
https://bit.ly/RBrilenkovYT
LinkedIn
/ ruslan-brilenkov
Medium
/ ruslan-brilenkov
========================================
Disclaimer 1: This royalty-free background music was generated with AI software and post-processed afterward. If you are tired of spending too much time and energy finding background music for your videos, dramatically reduce that time with Mix.audio!
Use the promo link below to get a 30% discount on your first monthly subscription payment, and by doing so, you will also support the channel at no extra cost to you:
https://bit.ly/ruslanpromoAI
========================================
Disclaimer 2: everything presented in this video is my own opinion and is meant to educate and share information, nothing mentioned or described here is legal or financial advice. Ruslan Brilenkov is not responsible for any profits or losses associated with your investment. So, please be responsible for your own actions.
На этой странице сайта вы можете посмотреть видео онлайн SQL Automation | PostgreSQL Triggers EXPLAINED | Step-by-step Syntax Tutorial | pgAdmin 4 длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Ruslan Brilenkov 10 Май 2024, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 71 раз и оно понравилось 5 зрителям. Приятного просмотра!