Summary
Keywords
Full Transcript
Sql Triggers🔫 Real Life Example A trigger in SQL is a set of instructions that automatically execute in response to specific events on a particular table or view. Triggers are typically used to enforce business rules, maintain audit trails, and automate tasks such as calculations or updates when changes are made to a database. Trigger Types BEFORE Trigger: Executes before an operation (INSERT, UPDATE, or DELETE) is completed. AFTER Trigger: Executes after an operation is completed. INSTEAD OF Trigger: Typically used on views to handle what happens instead of a default INSERT, UPDATE, or DELETE action. Want more similar videos- hit like, comment, share and subscribe ❤️Do Like, Share and Comment ❤️ ❤️ Like Aim 5000 likes! ❤️ ➖➖➖➖➖➖➖➖➖➖➖➖➖ script CREATE TABLE Employee ( employee_id INT PRIMARY KEY, employee_name VARCHAR(50), department_id INT, salary DECIMAL(10, 2) ); CREATE TABLE Backup_Employee ( backup_id INT IDENTITY(1,1) PRIMARY KEY, employee_id INT, employee_name VARCHAR(50), department_id INT, salary DECIMAL(10, 2), deleted_at DATETIME DEFAULT GETDATE() ); CREATE TRIGGER employee_delete ON Employee AFTER DELETE AS BEGIN INSERT INTO Backup_Employee (employee_id, employee_name, department_id, salary, deleted_at) SELECT employee_id, employee_name, department_id, salary, GETDATE() FROM DELETED; END; ➖➖➖➖➖➖➖➖➖➖➖➖➖ AWS DATA ENGINEER : https://www.youtube.com/playlist?list=PLOlK8ytA0MghpdMjb0m9zu1v9s_qbRP0q Azure data factory : https://youtube.com/playlist?list=PLOlK8ytA0MgguN5XidtQXbILxwCdJCUJE&si=iEICXHP80zGchUYh Azure data engineer playlist : https://youtube.com/playlist?list=PLOlK8ytA0MghBrzu0i6WlTBdoO1WdwV_e SQL PLAYLIST : https://www.youtube.com/playlist?list=PLOlK8ytA0MggGXIKmbfZ-_Xqcos3JKdV- PYSPARK PLAYLIST - https://www.youtube.com/playlist?list=PLOlK8ytA0MgjvOpd-088NRU_vTYw_aryH ➖➖➖➖➖➖➖➖➖➖➖➖➖ 📣Want to connect with me? Check out these links:📣 Join telegram to discuss https://t.me/+Cb98j1_fnZs3OTA1 ➖➖➖➖➖➖➖➖➖➖➖➖➖ what we have covered in this video: ➖➖➖➖➖➖➖➖➖➖➖➖➖ Hope you liked this video and learned something new :) See you in next video, until then Bye-Bye! ➖➖➖➖➖➖➖➖➖➖➖➖➖
