🔹 2️⃣ Delete Duplicate Records from a Table
👉 Keep only one record and remove duplicates:
WITH CTE AS (
SELECT *,
ROW_NUMBER() OVER (PARTITION BY Name, Email ORDER BY Id) AS rn
FROM Customers
)
DELETE FROM CTE WHERE rn > 1;
While learning PL/SQL, I found Triggers to be one of the most powerful concepts inside the database.
A Trigger is a block of PL/SQL code that automatically executes when a specific event happens on a table.
That event could be:
• INSERT
• UPDATE
• DELETE
Unlike procedures, triggers do not need to be called manually.
They run automatically when the defined condition is met.
For example:
In a banking system,
whenever a transaction is inserted into the transactions table,
a trigger can automatically update the account balance.
This ensures:
• Data consistency
• Automatic validation
• Reduced manual errors
Types of Triggers:
• BEFORE Trigger → Executes before the event
• AFTER Trigger → Executes after the event
• Row-level Trigger → Runs for each row affected
• Statement-level Trigger → Runs once per SQL statement
Key takeaway:
Triggers help enforce business rules and maintain data integrity directly inside the database.
Continuing to explore deeper into PL/SQL concepts 🚀
Understanding the difference between DELETE, TRUNCATE, and DROP is a small concept with a big impact in SQL.
🌱 DELETE
Removes specific rows using WHERE while keeping the table structure intact. Best when you need control over which data goes.
🌿 TRUNCATE
Quickly removes all rows, resets identity counters, and keeps the table structure. Ideal for clearing large tables efficiently.
🪵 DROP
Completely removes the table along with its structure. Once dropped, the table is gone for good.
Knowing when and why to use each command is essential for writing safe, efficient, and production-ready SQL queries.
Iqra Academia
4 months ago | [YT] | 0
View 0 replies
Iqra Academia
🔹 2️⃣ Delete Duplicate Records from a Table
👉 Keep only one record and remove duplicates:
WITH CTE AS (
SELECT *,
ROW_NUMBER() OVER (PARTITION BY Name, Email ORDER BY Id) AS rn
FROM Customers
)
DELETE FROM CTE WHERE rn > 1;
6 months ago | [YT] | 0
View 0 replies
Iqra Academia
🔹 Understanding Triggers in PL/SQL
While learning PL/SQL, I found Triggers to be one of the most powerful concepts inside the database.
A Trigger is a block of PL/SQL code that automatically executes when a specific event happens on a table.
That event could be:
• INSERT
• UPDATE
• DELETE
Unlike procedures, triggers do not need to be called manually.
They run automatically when the defined condition is met.
For example:
In a banking system,
whenever a transaction is inserted into the transactions table,
a trigger can automatically update the account balance.
This ensures:
• Data consistency
• Automatic validation
• Reduced manual errors
Types of Triggers:
• BEFORE Trigger → Executes before the event
• AFTER Trigger → Executes after the event
• Row-level Trigger → Runs for each row affected
• Statement-level Trigger → Runs once per SQL statement
Key takeaway:
Triggers help enforce business rules and maintain data integrity directly inside the database.
Continuing to explore deeper into PL/SQL concepts 🚀
#plsql #triggers #oracle #databasedevelopment #sql #learningjourney
6 months ago | [YT] | 0
View 0 replies
Iqra Academia
6 months ago | [YT] | 0
View 0 replies
Iqra Academia
6 months ago | [YT] | 0
View 0 replies
Iqra Academia
Understanding the difference between DELETE, TRUNCATE, and DROP is a small concept with a big impact in SQL.
🌱 DELETE
Removes specific rows using WHERE while keeping the table structure intact. Best when you need control over which data goes.
🌿 TRUNCATE
Quickly removes all rows, resets identity counters, and keeps the table structure. Ideal for clearing large tables efficiently.
🪵 DROP
Completely removes the table along with its structure. Once dropped, the table is gone for good.
Knowing when and why to use each command is essential for writing safe, efficient, and production-ready SQL queries.
6 months ago | [YT] | 0
View 0 replies