Lab Manual
Lab Manual
1. Data Definition Language (DDL) Commands for Base Tables and Views
Aim:
To understand and practice Data Definition Language (DDL) commands for creating base tables
and views in SQL.
Algorithm:
1. Use the CREATE TABLE command to define the structure of a base table.
2. Use the CREATE VIEW command to define a virtual table based on a query.
3. Use the ALTER TABLE command to modify an existing table.
4. Use the DROP TABLE and DROP VIEW commands to remove tables and views.
Program:
-- Create View
CREATE VIEW EmployeeView AS
SELECT EmpID, EmpName
FROM Employee WHERE Salary > 5000;
-- Drop Table
DROP TABLE Employee;
-- Drop View
DROP VIEW EmployeeView;
Output:
Result:
Successfully demonstrated DDL commands like CREATE, ALTER, and DROP for base tables and
views.
24UDSMP202 LAB MANUAL DSC PRACTICAL IV: DBMS LAB
2. Data Manipulation Language (DML) Commands for Base Tables and Views
Aim:
To practice Data Manipulation Language (DML) commands for inserting, updating, and deleting
records in base tables and views.
Algorithm:
Program:
Output:
Result:
Successfully executed DML commands like INSERT, UPDATE, DELETE, and SELECT.
Aim:
To create an Employee database and set various constraints like NOT NULL, PRIMARY KEY,
FOREIGN KEY, UNIQUE, and CHECK.
Algorithm:
Program:
Output:
Result:
Successfully created the Employee database and applied constraints.
Aim:
To establish relationships between different tables in a database using primary and foreign keys.
Algorithm:
Program:
Output:
Result:
Successfully created relationships between the Employee and Manager tables.
Aim:
To create a table and use built-in functions and perform data grouping with GROUP BY.
Algorithm:
1. Create a table.
2. Use built-in functions like COUNT(), SUM(), AVG().
3. Group data based on a specific column using GROUP BY.
Program:
Output:
● Displays the number of sales and total sales amount per salesperson.
Result:
Successfully performed built-in functions like COUNT(), SUM(), and grouped data using GROUP
BY.
Aim:
To create a table and implement different types of constraints like NOT NULL, CHECK, DEFAULT,
UNIQUE, and PRIMARY KEY.
Algorithm:
Program:
Output:
Result:
Successfully created the table with different types of constraints.
Aim:
To perform SQL joins and set operations (UNION, INTERSECT, EXCEPT).
Algorithm:
24UDSMP202 LAB MANUAL DSC PRACTICAL IV: DBMS LAB
Program:
Output:
● Data from Orders and Customers tables is retrieved using an INNER JOIN.
● A union of customer names from both tables is displayed.
Result:
Successfully performed JOIN and set operations (UNION, INTERSECT, EXCEPT).
Aim:
To create a table and perform aggregate functions like SUM(), AVG(), MAX(), and MIN().
Algorithm:
1. Create a table.
2. Use aggregate functions to calculate summaries.
Program:
24UDSMP202 LAB MANUAL DSC PRACTICAL IV: DBMS LAB
Output:
Result:
Successfully performed aggregate functions.
Aim:
To create a table and implement a trigger in SQL.
Algorithm:
1. Create a table.
2. Write a trigger to perform actions automatically on certain events.
Program:
Output:
24UDSMP202 LAB MANUAL DSC PRACTICAL IV: DBMS LAB
Result:
Successfully implemented a trigger to enforce salary constraints.
Aim:
To understand and perform basic PL/SQL operations.
Algorithm:
1. Create a table.
2. Write a PL/SQL block for inserting records and handling errors.
Program:
Output:
Result:
Successfully implemented PL/SQL for inserting data into the table.