LAb Output
LAb Output
(a)Write and execute a program to implement Row Level and Statement Level Triggers
(b) Write and execute transaction control languages
a. Output :
Notes:
Sql
b. AccID | Balance
--------------
1 | 1000
2 | 2000
AccID | Balance
--------------
1 | 900
2 | 2000
AccID | Balance
--------------
1 | 900
2 | 2100
AccID | Balance
--------------
1 | 900
2 | 2000
Output Summary:
After First Update:
o Account 1: Balance reduced to 900.
After Savepoint Creation:
o No visible output; SAVEPOINT sp1 is created.
After Second Update:
o Account 2: Balance temporarily increased to 2100.
After Rollback to Savepoint:
o Account 2: Balance reverted to 2000.
After Commit:
o Transaction committed. Changes to Account 1 balance are now
permanent.
(b) Cartesian Product, Equi Join, Left Outer Join, Right Outer Join and Full Outer Join
1. Employee Table:
markdown
Copy code
EmpID | Name | Salary
-----------------------
1 | Alice | 50000
2 | Bob | 60000
2. Department Table:
markdown
Copy code
DeptID | DeptName
-----------------
1 | HR
2 | IT
Insert:
sql
Copy code
INSERT INTO Employee VALUES (3, 'Charlie', 70000);
INSERT INTO Department VALUES (3, 'Finance');
Employee Table:
markdown
Copy code
EmpID | Name | Salary
-------------------------
1 | Alice | 50000
2 | Bob | 60000
3 | Charlie | 70000
Department Table:
markdown
Copy code
DeptID | DeptName
-----------------
1 | HR
2 | IT
3 | Finance
Delete:
sql
Copy code
DELETE FROM Employee WHERE EmpID = 2;
Employee Table:
markdown
Copy code
EmpID | Name | Salary
-------------------------
1 | Alice | 50000
3 | Charlie | 70000
Update:
sql
Copy code
UPDATE Employee SET Salary = 80000 WHERE EmpID = 3;
Employee Table:
markdown
Copy code
EmpID | Name | Salary
-------------------------
1 | Alice | 50000
3 | Charlie | 80000
(b) Joins
Cartesian Product:
sql
Copy code
SELECT * FROM Employee, Department;
Output:
markdown
Copy code
EmpID | Name | Salary | DeptID | DeptName
--------------------------------------------
1 | Alice | 50000 | 1 | HR
1 | Alice | 50000 | 2 | IT
1 | Alice | 50000 | 3 | Finance
3 | Charlie | 80000 | 1 | HR
3 | Charlie | 80000 | 2 | IT
3 | Charlie | 80000 | 3 | Finance
Equi Join:
sql
Copy code
SELECT e.EmpID, e.Name, e.Salary, d.DeptName
FROM Employee e, Department d
WHERE e.EmpID = d.DeptID;
Output:
markdown
Copy code
EmpID | Name | Salary | DeptName
------------------------------------
1 | Alice | 50000 | HR
Output:
All rows from Employee with matching Department rows and NULL for non-match-
ing:
markdown
Copy code
EmpID | Name | Salary | DeptName
------------------------------------
1 | Alice | 50000 | HR
3 | Charlie | 80000 | NULL
Output:
All rows from Department with matching Employee rows and NULL for non-match-
ing:
sql
Copy code
EmpID | Name | Salary | DeptName
------------------------------------
1 | Alice | 50000 | HR
NULL | NULL | NULL | IT
NULL | NULL | NULL | Finance
Output:
All rows from both tables, with NULL for non-matching entries:
sql
Copy code
EmpID | Name | Salary | DeptName
------------------------------------
1 | Alice | 50000 | HR
3 | Charlie | 80000 | NULL
NULL | NULL | NULL | IT
NULL | NULL | NULL | Finance
(a) Write and execute transaction control languages
6.
(i)Commit, rollback and save points.
(iii)Nested Queries
Output:
-----------------
1 | Alice
Output:
Average TotalAmount is 650.00, so the query retrieves orders with amounts greater
than this value:
markdown
Copy code
OrderID | CustomerName | TotalAmount
------------------------------------
2 | Bob | 700.00