Database Management System
Database Management System
MISSION
QUALITY POLICY
We, at MSBTE, are committed to offer the best-in-class academic services to the students
and institutes to enhance the delight of industry and society. This will be achieved
through continual improvement in management practices adopted in the process of
curriculum design, development, Implementation, evaluation, and monitoring system
along with adequate faculty development programmes.
CORE VALUES
for
Maharashtra State
Board of Technical Education, Mumbai
(Autonomous) (ISO-9001-2008)
(ISO/IEC 27001:2013)
MAHARASHTRA STATE
BOARD OF TECHNICAL EDUCATION
Certificate
This is to certify that Mr. / Ms. ………………………………………………………………….
Roll No………………………. of Third Semester of Diploma in………………………….
………………………………………………..…………of Institute ……………………………
………………………………………………………………………..(Code ……………..)
has completed the term work satisfactorily in course Database Management System
(313302) for the academic year 20…….to 20…..... as prescribed in the curriculum.
This laboratory manual is designed to help all stakeholders, especially the students, teachers and
instructors to develop in the student the pre-determined outcomes. It is expected from each student
that at least a day in advance, they must thoroughly read the concerned practical procedure that
they will do the next day and understand minimum theoretical backgroundassociated with the
practical. Every practical in this manual begins by identifying the competency, industry relevant
skills, course outcomes and practical outcomes which serve as a key focal point for doing the
practical. Students will then become aware of the skills they willachieve through procedure shown
there and necessary precautions to be taken, which will help them to apply in solving real-world
problems in their professional life.
This manual also provides guidelines to teachers and instructors to effectively facilitate student-
centered lab activities through each practical exercise by arranging and managing necessary
resources in order that the students follow the procedures and precautions systematically ensuring
the achievement of outcomes in the students.
A database management system is needed to organize, store, and manage large amounts of data
efficiently. It ensures data is easily accessible, secure, and can be quickly updated or retrieved
when needed. This helps businesses and organizations make better decisions and operate smoothly.
The lab manual development team wishes to thank MSBTE who took initiative in the development
of curriculum re-design project and implementation and acknowledge the
contribution of individual course experts who have been involved in laboratory manual
as well ascurriculum development (K scheme) directly or indirectly.
Although all care has been taken to check for mistakes in this laboratory manual, it is
impossible to claim perfection, especially as this is the first edition. Any such errors
and suggestions for improvement can be brought to our notice and are highly welcome.
PSO1. Modern Information Technology: Use latest technology for operation and
application of information.
PSO2. Information Technology Process: Maintain the information process using modern
information and communication technologies
4
* Execute DML Commands
to manipulate data using √
SQL.
5
* Execute DCL commands to
√
control the access to data using SQL
6
* Execute TCL Commands to
control transactions on data using √
SQL
7 Write Queries using Arithmetic
√
operators.
8 Apply built-in Logical operators on given
data √
The following industry relevant skills of the competency “To design database and use any
RDBMS package as a backend for developing database applications” are expected to be
developed in you by performing practicals of this laboratory manual.
Students shall read the points given below to understand the theoretical concepts andpractical
applications.
1. Students shall listen carefully to the lecture given by the teacher about importance of the
subject,learning structure, course outcomes.
2. Students shall organize the work in a group of two or three members and make arecord of
all observations.
3. Students shall understand the purpose of the experiment and its practical implementation.
4. Students shall write the answers to the questions during practical.
5. Students should feel free to discuss any difficulty faced during the conduct of practical.
6. Students shall develop knowledge of Database Management System fundamentals and
manipulation skills as expected by the industries.
7. Students shall attempt to develop related hands-on skills and gain confidence.
8. Students shall refer technical magazines; websites related to the scope of the subjects
and update their knowledge and skills.
9. Students shall develop self-learning techniques.
10. Students should develop the habit of submitting the write-ups on the scheduled dates and
time.
Content Page
The aim of this course is to design databases and use any RDBMS package as a backend
for developing database applications
III. Course level learning outcomes
This practical is expected to develop the following skills in you:
1. Understand what is Database management system software.
2. Install the relevant database system software.
Step1:
Step 2:
Download Oracle database 21c express edition for windows depending on your windows
configuration. Choose the location as per the requirements and download the compressed
zip file.
Step 3:
Follow the Installation procedure and provide the proper Username and password.
Step 4:
Open the SQL PLUS and provide the proper credentials to open it. The Oracle express
edition is now ready to use.
2. https://support.microsoft.com/en-us/office/database-design-basics-eb2159cf-1e30-
401a-8084-bd4f9c9ca1f5
X. Assessment Scheme
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
Syntax:
CREATE DATABASE database_name;
Example:
create database employee;
Re Relevant LLO
Sr. Equipment Name with Broad Specifications
Number
No
Computer system with all necessary components like; motherboard, random
1 access memory (RAM), read-only memory (ROM), internal hard disk All
drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition,MySql,SQLite,Oracle Live SQL etc.
VIII. Procedure
1. Create Database for given application
2. Create tables for the given application
3. Assign Primary key for created table
4. Modify the table as per the application needs.
IX. Result(s)
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XI. Exercise
1. How would you create a new database named EMP?
2. Write the SQL commands to create the EMP table with the following structure:
• empno as a number datatype with up to 4 digits
• ename as a variable character datatype up to 10 characters
• job as a variable character up to 9 characters
• mgr as a number datatype with up to 4 digits
• hiredate as a date
• sal as a number with up to 7 digits, including 2 decimal places
• comm as a number with up to 7 digits, including 2 decimal places
• deptno as a number with up to 2 digits
3. How would you alter the EMP table to assign the empno column as the primary
key?
4. Write the SQL commands to create the DEPT table with the following structure:
• deptno as a number with up to 2 digits
• dname as a variable character datatype up to 10 characters
• loc as a variable character up to 20 characters
4. https://support.microsoft.com/en-us/office/database-design-basics-eb2159cf-1e30-
401a-8084-bd4f9c9ca1f5
XIII. Assessment Scheme
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
I. Practical Significance
DDL commands are used to define database structure or Schema. DDL deals with
description of database schema. It is used to create and modify the structure of database
objects. DDL provides a set of definition to specify storage structure and access
methods used by the database system. Design database by applying the constraints and
modify the structure of table. This practical will help students to create and modify the
database.
II. Industry/Employer Expected Program Outcomes (POs)
The aim of this practical is to design databases and modify the database structure as per
the database applications.
III. Course level learning outcomes
This practical is expected to develop the following skills in you:
1. Understand how to design the Database system based on the requirements
2. Modify the structure of the database and apply the constraints.
IV. Laboratory Learning Outcome(s)
1. Write and execute SQL queries for creating database.
2. Write queries to Modifying the database.
3. Write queries to apply suitable constraints.
5. LONG
6. RAW/LONG RAW
7. MISCELLANUOUS (clob, blob, xml, Json)
DDL Commands:
It is a set of SQL commands used to create, modify and delete database structure but not
the data. These commands normally used by Database administrator (DBA).
1. CREATE
2. ALTER
3. DROP
4. RENAME
5. TRUNCATE
6. DESCRIBE
Create Tables for the Given Application:
Syntax:
CREATE TABLE table _name (column1 name datatype(size), column2 name
datatype(size)…...);
Modify the Table as per the Application:
Syntax:
ALTER TABLE table_name ADD column_name datatype;
or removing a column:
ALTER TABLE table_name DROP COLUMN column_name;
Procedure:
1. Create Database for given application
VIII. Precautions
1) Use of appropriate syntax
2) Select required relations and use relevant conditions.
IX. Additional Resources used
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………
X. Result (Output of the procedure)
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………
XI. Practical Related Questions
Note: Below are few sample questions for reference. Teacher must design more such
questions so as to ensure the achievement of identified CO.
(Note: Use Point VII and XIII to XV for all relevant practical exercise use blank
pages provided or attach more pages if needed.)
1. Create a table EMPLOYEE with following schema:
Emp (EMP_no as primary key, E_name, Dept_no, Dept_name, Job_id, salary)
2. Create tables EMPLOYEE and DEPARTMENT with following schema by applying
Primary and Foreign key:
Emp(empno as primary key, empname, salary, phoneno)
Dept(deptno primary key, empno foreign key, deptname, location).
Theory related Questions
1. List DDL commands with its syntax
2. List different SQL Binary datatypes
3. Write difference between Drop and Truncate command.
4. Write the use of Describe command.
(Space for answers)
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
………………………………………………………………………………………
XII. Exercise
Attempt following and teacher shall design and allot more questions to attain
desired outcome: (Note: Use Point VIII to X and XIII to XV for all relevant
programming exercise use blank pages provided or attach more pages if needed.)
1. Create table for stud using attributes Rollno, Studname, Percentage. Apply primary
key for rollno and check constraint on percentage that the percentage should not be
greater than 100.
2. Change the stud table structure by adding column City.
3. Increase the size by 10 of studentname column.
4. Write the output of the following:
1. Create table Output:
Passenger_details(passenger_name
varchar2(30), train_details
varchar2(30),travelling_date date,
birthdate date);
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
Explanation: The INSERT command is used to add new rows of data to a table.
Syntax:
1) INSERT INTO emp (empno, name, age) VALUES (1, 'Aditya Shinde', 20);
2) INSERT INTO emp VALUES (1, 'Aditya Shinde', 20);
3) INSERT INTO emp (empno , Age) VALUES (1, 20);
2. UPDATE
Syntax:
UPDATE table_name
WHERE condition;
Example:
UPDATE emp
SET age = 21
WHERE empno = 1;
3. DELETE
Explanation: The DELETE command is used to remove existing rows from a table.
Syntax:
WHERE condition;
Example:
The following syntax is used to display data of specific columns from the table.
Syntax:
Example:
Summary Table:
Relevant LLO
Sr. Equipment Name with Broad Specifications
Number
No
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition, MySql, SQLite,Oracle Live SQL etc.
VIII. Procedure
1. Create Database for given application
2. Follow syntax to modify the table according to question.
IX. Result(s)
…………………………………………………………………………………………………
…………………………………………………………………………………………….
………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………….
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
XI. Exercise
1. Using various syntax of insert command insert the following rows of data in
the EMP table.
EMPNO ENAME DNAME JOB HIREDATE LOC
7876 ADAMS RESEARCH CLERK DALLAS
23-MAY-87
7499 ALLEN SALES SALESMAN
20-FEB-81
CHICAGO
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
Experiment No. 5: Execute DCL commands to control the access to data using SQL
I. Practical Significance
DCL stands for Data Control Language. This command is used to provide different
user access to the stored data. It enables the data administrator to Grant and Revoke the
required access to the database. The DCL commands are easier to implement with its
simple syntax.
II. Industry/Employer Expected Program Outcomes (POs)
The aim of this practical is to create user and give access to users using Grant command
and deny access using revoke command.
III. Course level learning outcomes
This practical is expected to develop the following skills in you:
1. Understand how to design the Database system based on the requirements.
2. Create user/ multiple users.
3. Provide access to Database.
4. Deny access to Database
IV. Laboratory Learning Outcome(s)
1. Write and execute SQL queries for creating Users.
2. Write queries for providing access to User to database.
3. Write queries to deny access to User.
V. Relevant Affective domain related Outcome(s)
1. Follow ethical practices.
2. Use appropriate DBMS software.
3. Demonstrate analytical and logical knowledge as an Individual.
4. Participate in team problem solving activities.
5. Prioritizes time effectively to meet the needs of the team and self.
VI. Minimum Theoretical Background
DDL Commands:
The Database Administrator has authority to create as many users as needed. The user is
created using the CREATE USER command. Privileges is a right to execute the SQL
statement or to access object. There are two types of privileges.
SYSTEM privileges: It is generally granted by DBA to users. Example: Create table, create
user etc.…
OBJECT privileges: This allows access to objects or privileges on objects, that is tables,
table columns, Tables, Views etc. It includes Alter, delete, insert, select, update commands.
The DBA user the GRANT statement to allocate system privileges to another user. The
REVOKE command is used to remove privileges granted to users.
VII. Additional Software required
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
…………………………………………………………………………
VIII. Precautions
1) Use of appropriate syntax
1. Create the user Jay and implement the following commands on table EMP and Dept.
2. Write a query to grant select, insert, delete privileges on Emp and Dept table.
3. Write a query to grant update privilege on columns of empno and salary on Emp
table.
4. Write a query to revoke all above privileges from Emp and Dept table.
5. Write a query to create role dept_pvr.
6. Write a query to assign system privileges- create table, create view to role dept_pvr;
7. Write a query to assign above system privileges to users Jay and John.
8. Write a query to assign object privileges- select, insert, delete to role dept_pvr.
9. Write a query to assign above object privileges to users’ jay and john.
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
Experiment No 06: Execute TCL Commands to control transactions on data using SQL
1. COMMIT
Explanation: The COMMIT command is used to save all changes made during the current
transaction to the database permanently.
Syntax:
COMMIT;
Example:
update emp
set sal = sal + 5000
where empno = 101;
commit;
The salary increases for the employee with empno = 101 is saved permanently in the database.
2. ROLLBACK
Explanation: The ROLLBACK command is used to undo changes made during the current
transaction, reverting the database to its previous state.
Syntax:
ROLLBACK;
Example:
update emp
set sal = sal+ 5000
where empno = 101;
rollback;
The salary increases for the employee with empno = 101 is undone, and the database
returns to its state as it was before the execution of update command.
3. SAVEPOINT
Explanation: The SAVEPOINT command is used to set a savepoint within a transaction,
allowing for partial rollbacks to specific points within the transaction.
Syntax:
SAVEPOINT savepoint_name;
Example:
SAVEPOINT BeforeUpdate;
update emp
set sal = sal + 5000
where empno = 101;
rollback to BeforeUpdate;
The salary increases for the employee with EmployeeID = 101 is undone, and the
Summary Table
Relevant LLO
Sr.No Equipment Name with Broad Specifications
Number
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition, MySql,SQLite,Oracle Live SQL etc.
VIII. Procedure
1. Create Database for given application
2. Create tables for the given application
3. Execute TCL Commands after DML Commands
IX. Result(s)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………
3. Describe savepoint
4. Describe states of transaction with neat diagram
5. Describe ACID properties of transaction
(Space for answer)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………
XI. Exercise
1. Write TCL command to save all the changes made so far in the EMP
2. Delete any one record in the EMP table created earlier and undo the deletion
operation
3. You are in the middle of a transaction and want to set a savepoint named
BeforeSalaryUpdate. Write the SQL command to set this savepoint.
XII. References/Suggestions for further reading: include websites/links
1. https://www.youtube.com/watch?v=LSB4eceRsw8
2. https://www.youtube.com/watch?v=yGU4YfSSjdM
3. https://www.javatpoint.com/tcl-commands-in-sql
4. https://www.programiz.com/sql/tcl-commands
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
I. Practical Significance:
The arithmetic operators are used on the data stored in the tables. We can use these
operators with the SELECT statement in SQL. We can also use WHERE clause in the
SELECT statement for performing operations on particular rows. The arithmetic
operators are used between two numerical operands for performing addition,
subtraction, multiplication and division operations. This practical allows students to
write SQL queries using arithmetic operators and performs mathematical operations on
the data stored in the tables.
Serial
Operator Name Explanation Syntax
Number
The addition SELECT
1 ADDITION
plus (+) operator is used <Expression>[arithmetic
Compound Operators:
Operator Operator Name Explanation
+= += (Add Assignment) (Transact- Adds some amount to the original value
SQL) and sets the original value to the result.
-= -= (Subtract Assignment) (Transact- Subtracts some amount from the original
SQL) value and sets the original value to the
result.
*= *= (Multiply Assignment) (Transact- Multiplies by an amount and sets the
SQL) original value to the result.
/= (Divide Assignment) (Transact-SQL) Divides by an amount and sets the
original value to the result.
%= Modulus Assignment (Transact- Divides by an amount and sets the
SQL) original value to the modulo.
Maharashtra State Board of Technical Education (‘K Scheme’) 33
DATABASE MANAGEMENT SYSTEM (313302)
&= &= (Bitwise AND Assignment) Performs a bitwise AND and sets the
(Transact-SQL) original value to the result.
^= ^= (Bitwise Exclusive OR Performs a bitwise exclusive OR and sets
Assignment) (Transact-SQL) the original value to the result.
|= |= (Bitwise OR Assignment) Performs a bitwise OR and sets the
(Transact-SQL) original value to the result.
Relevant LLO
Sr.No Equipment Name with Broad Specifications
Number
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition, MySQL, SQLite, Oracle Live SQL etc.
VIII. Procedure
1. Create tables for the given application
2. Apply Arithmetic operators on the given application
IX. Result(s)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………………
……………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………………
……………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………
………………………………………………………………………………………………
XI. Exercise
1. Consider the following schema
Orders(cust_id, order_id, items, amount)
Write queries for the following:
i. Display new column named total_amount which is 200 added to the amount
field.
ii. Display new column named offer_price which is 100 subtracted from the
amount field.
iii. Display new column named revised_amount which is multiplied by 5 times
the amount field.
iv. Display new column named half_amount which is divided by 2 to the
amount field.
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
Operator
Sr No. Explanation Syntax SQL Query Example
Name
Returns true if both Select * SELECT * FROM
conditions are true from employees WHERE
tablename age > 30 AND salary >
1 AND where 50000;
condition1
AND
condition2;
Returns true if either Select * SELECT * FROM
condition is true from employees WHERE
2 OR tablename department = 'IT' OR
where department = 'HR';
condition1
OR
condition2;
Returns true if the NOT SELECT * FROM
3 NOT condition is false condition employees WHERE NOT
department = 'Finance';
Returns true if a value is Select * SELECT * FROM
within a range from employees WHERE age
tablename BETWEEN 25 AND 35;
4 BETWEEN where
BETWEEN
low AND
high;
Returns true if a value Select * SELECT * FROM
matches any in a list from employees WHERE
tablename department
5 IN
where IN ('IT', 'Finance');
columnname
IN (list);
Returns data based on a value LIKE SELECT * FROM
specified pattern, using pattern employees WHERE name
'%' and '_' as wildcard LIKE 'P%';
characters for pattern
matching. Note:
• %: Matches zero or • P%: Matches strings
more characters. that start with "P"
• _: Matches any followed by any
6 LIKE single character. characters.
• %P: Matches strings
that end with "P", with
any characters
preceding it.
• %P%: Matches strings
that contain "P"
anywhere, surrounded
by any characters.
Relevant LLO
Sr.No Equipment Name with Broad Specifications
Number
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition,MySql,SQLite,Oracle Live SQL etc.
VIII. Procedure
1. Create tables for the given application
2. Apply logical operators on the given application
IX. Result(s)
………………………………………………………………………………………………
………………………………………………………………………………………………
X. Practical related questions (Provide space for answers)
Note: Below are a few sample questions for reference. Teacher must design more
suchquestions so as to ensure the achievement of identified CO.
1. Explain the need of logical operators in SQL
2. List three logical operators and describe them with an example.
(Space for answer)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XI. Exercise
1. Consider the following schema
Emp(empno,ename,job,mgr,hiredate,sal,comm,deptno)
Write queries for the following:
i. Display employees whose city is ‘Mumbai’ and earns more than 50000
ii. Display employees who job is Clerk or commission is 500
iii. Display details of employees whose salary is between 20000 and 50000.
iv. Display details of employees who stays at Mumbai, Pune, Nashik or Nagpur
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
I. Practical Significance:
The Relational operators in SQL is used to compare two expressions or values and
return a Boolean result. The Relational operators are used on the data stored in the
tables. We can use these operators with the WHERE clause in the SQL queries.
Serial
Operator
Num Explanation Syntax/example
Name
ber
This operator is highly used in SQL SELECT * FROM Employee
SQL Equal
queries. The Equal Operator in WHERE Gender = ‘Male’;
1 Operator
SQL shows only data that matches
(=)
the specified value in the query.
SQL Equal The Equal Not Operator in SQL SELECT * FROM Employe
Not shows only those data that do not e_details WHERE Emp_Sal
2
Operator (! match the query's specified value. ary! = 45000;
=)
SQL SELECT * FROM Employe
3 Greater The Greater Than Operator in e_details WHERE Emp_Id
Than SQL shows only those data which > 202;
Relevant LLO
Sr.No Equipment Name with Broad Specifications
Number
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition, MySQL, SQLite, Oracle Live SQL etc.
VIII. Procedure
1. Create tables for the given application
2. Apply Relational operators on the given application
IX. Result(s)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
………………………………………………………………………………………………
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
I. Practical Significance: Set operators in SQL help to combine and compare the
results of two or more queries. You can use set operators to find common elements,
unique elements, or differences between tables. This makes it easier to analyze and
understand your data. Students will learn to manipulate and analyze data by
combining and comparing multiple datasets using set operators in SQL.
Serial
Operator Description Syntax SQL Query Example
Number
1 UNION Combines two SELECT * FROM SELECT * FROM emp
Relevant LLO
Sr.No Equipment Name with Broad Specifications
Number
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition,MySql,SQLite,Oracle Live SQL etc.
VIII. Procedure
1. Create tables for the given application
2. Apply set operators on the given tables
IX. Result(s)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
I. Practical Significance:
The string is a collection of characters used to store multiple characters. Most of the
time we need to modify and access the strings. SQL has built-in string functions. The
SQL built-in string functions take an input string and return an output string. String
functions are used to perform various character manipulations.
Relevant LLO
Sr.No Equipment Name with Broad Specifications
Number
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition,MySql,SQLite, Oracle Live SQL etc.
Maharashtra State Board of Technical Education (‘K Scheme’) 50
DATABASE MANAGEMENT SYSTEM (313302)
VIII. Procedure
Execute SQL queries using String functions
IX. Result(s)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………
XI. Exercise:
1. Write output of the following queries.
2. Select concat (‘Jay’ ‘IITB’) from Dual;
3. Select ltrim (‘Shreya’,’s’) from Dual;
4. Select upper(‘raj’) from Dual;
5. Select rpad (“HR’, 10, ‘*’) from Dual;
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
Relevant LLO
Sr.No Equipment Name with Broad Specifications
Number
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition,MySql,SQLite, Oracle Live SQL etc.
VIII. Procedure
Execute SQL queries using arithmetic functions
IX. Result(s)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
X. Practical related questions (Provide space for answers)
Note: Below are a few sample questions for reference. Teacher must design more
suchquestions so as to ensure the achievement of identified CO.
1. Differentiate between round() and trunc()
2. Differentiate between floor() and ceil()
3. List arithmetic functions which are not listed here.
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
I. Practical Significance:
SQL Date and Time operations are used for operations on date and time provided by
users. As long as your data contains only the date portion, your queries will work as
expected. However, if a time portion is involved, it gets more complicated. SQL
supports various date and time data types and formats. The specific date format
depends on the database system you are using.
Relevant LLO
Sr.No Equipment Name with Broad Specifications
Number
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition,MySql,SQLite, Oracle Live SQL etc.
VIII. Procedure
Execute SQL queries using date and Time functions.
IX. Result(s)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
X. Practical related questions (Provide space for answers)
Note: Below are a few sample questions for reference. Teacher must design more
suchquestions so as to ensure the achievement of identified CO.
1. Write the use of format () function with syntax and example.
2. Write the use of months_between function with syntax and example.
3. Write the syntax for displaying the local time stamp.
3. https://www.javatpoint.com
4. www.tutorialsteacher.com
5. www.w3schools.com
XIII. Assessment Scheme
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
nulls
COUNT (DISTINCT Counts distinct non-null values SELECT COUNT(DISTINCT
7
column_name) in specified column deptno) FROM emp;
Relevant LLO
Sr.No Equipment Name with Broad Specifications
Number
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition,MySql,SQLite,Oracle Live SQL etc.
VIII. Procedure
1. Create tables for the given application
2. Write SQL queries using aggregate functions
IX. Result(s)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
X. Practical related questions (Provide space for answers)
Note: Below are few sample questions for reference. Teacher must design more such
questions so as to ensure the achievement of identified CO.
1. Describe group functions or aggregate functions in SQL
2. Differentiate between count(*) and count(columname)
(Space for answer)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
Maharashtra State Board of Technical Education (‘K Scheme’) 63
DATABASE MANAGEMENT SYSTEM (313302)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XI. Exercise
Consider the following schema
Emp(empno,ename,job,mgr,hiredate,sal,comm,deptno)
1. Display the minimum, maximum, sum and average salary of all employees. Label
the columns Maximum, Minimum, Sum and Average respectively.
2. Determine the number of managers without listing them. Label the column number
of managers
3. Write a query that will display the difference between the highest and lowest
salaries. Label the column DIFFERENCE.
4. Display the number of employees in department 10 who earns a commission
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
I. Practical Significance:
This practical will help students to understand different clauses used in SQL. The
clauses are used to retrieve the information from the table. SQL clause helps us to
retrieve a set or bundles of records from the table. SQL clause helps us to specify a
condition on the columns or the records of a table. Different clauses available in the
Structured Query Language are as follows: WHERE CLAUSE, GROUP BY
CLAUSE, HAVING CLAUSE, ORDER BY CLAUSE.
Relevant LLO
Sr. Equipment Name with Broad Specifications
Number
No
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition, MySQL, SQLite, Oracle Live SQL etc.
VIII. Procedure
Execute SQL queries using different WHERE, HAVING, GROUPBY, ORDER BY
clause.
IX. Result(s)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
X. Practical related questions (Provide space for answers)
Note: Below are a few sample questions for reference. Teacher must design more
suchquestions so as to ensure the achievement of identified CO.
Create Two Tables Emp and Dept, Consider the following schema
Emp (Emp_no as primary key, E_name, Dept_no, Dept_name, name, Job_id, Salary)
and Dept (Dept_no as primary key, emp_no foreign key, deptname, location)
1. Display the information of the tables using SELECT command.
2. Execute the SQL queries using SELECT, WHERE, GROUP BY clause.
3. Execute the SQL queries using SELECT, WHERE, GROUP BY and HAVING clause.
4. Execute the SQL queries using SELECT, WHERE, ORDER BY clause.
5. Write the advantages of using the Order By clause.
(Space for answer)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XI. Exercise:
1. Write output of the following queries.
a. Display minimum salary of employee from every department;
b. Display total salary of every department.
c. Display the department having total employees more than 5.
d. Display details of employees with employee name in ascending order.
a. Display emp_no, dept_no from dept Group By deptname.
1. https://www.oreilly.com/library/view/oracle-plsql-programming/0596003811/ch09s03.html
2. https://beginner-sql-tutorial.com/oracle-functions.htm
3. https://www.javatpoint.com
4. www.tutorialsteacher.com
5. www.w3schools.com
XIII. Assessment Scheme
Performance indicators Weightage
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
Experiment No 16: Implement SQL queries for Inner and Outer Join
I. Practical Significance:
Join is used to combine the data spread across tables. A join is performed by the 'where'
clause which combines the specified rows of tables. This practical allows students to join
two or more tables.
values in WHERE
both tables. emp.deptno =
dept.deptno;
2 Non A join using SELECT SELECT e. Rows from
Equi- relational columns FROM ename, e. salary, emp and
Join operators table1, table2 s. grade FROM salgrade where
other than = WHERE emp.salary
emp e, salgrade s
(e.g., <, >, table1.column1 < falls between
WHERE
<=, >=, !=). table2.column2; salgrade.losal
e.salary and
BETWEEN salgrade.hisal.
s.losal AND
s.hisal;
OR
Equi -join
A join, which is based on equalities, is called equi-join. In equi-join comparison
operator equal to (=) is used to perform a join. It retrieves rows from tables having a
common column. It is also called simple join.
Syntax: select table1.column, table1.column,table2.column,….,
from table1, table2
where table1.column1 = table2.column2;
Example:
Select emp.empno,emp. ename,emp.deptno,
dept.deptno,dept.loc
from emp, dept
where emp.deptno = dept. deptno;
Guidelines:
1. Rows in one table can be joined to rows in another table according to the common
values existing in corresponding columns, that are usually primary and foreign key
columns.
2. When writing a select statement that joins tables, precede the column name with the
table name. (e.g. dept.deptno)
3. If the same column name appears in more than one table, the column name must be
prefixed to the table name. (e.g. dept.deptno, emp.deptno)
4. If the column names are unique, then we need not prefix it with the table name.
Note: - The above example is same as example of equi join but uses table aliases where
'e' refers to emp table and 'd' refers to dept table.
Non equi-join
A join that specifies the relationship between columns belonging to different tables by
making use of the relational operators (<, >, <=, >=, ! =) other than '=' operator is
called as non equi-join.
To use non equi-join create the following table.
Table - Salgrade
Column-name Datatype
Grade Number (4)
Losal Number (8)
Hisal Number (8)
Example:
select e.ename, e.salary, s.grade
from emp e, salgrade s
where e.salary
between s.losal and s.hisal;
OR
Self-join
Joining a table to itself is known as self-join. i.e. it joins one row in a table to another.
It can compare each row of the table to itself and with other rows of the same table.
Example: To find the name of each employee's manager you need to join EMP table to
itself.
Note:
The above example joins the emp table to itself. To stimulate two tables in the FROM
clause, there are two aliases, namely WORKER and MANAGER, for the same table,
EMP.
Outer Join
An outer join returns all the rows returned by simple join or equi join as well as those
rows from one table that do not match any row from the other table.
Consider following tables for outer join:
EMP Table
emp_id ename dept_id
1 Riya 1
2 Pranav 2
3 Mansi NULL
DEPT Table
dept_id dept_name
1 HR
2 IT
3 Finance
Description: The LEFT OUTER JOIN returns all records from the left table (EMP),
and the matched records from the right table (DEPT). The result is NULL from the
right side, if there is no match.
Syntax:
SELECT columns
FROM EMP
LEFT OUTER JOIN DEPT
ON EMP.dept_id = DEPT.dept_id.
Example:
SELECT EMP.emp_id, EMP.name, DEPT.dept_name
FROM EMP
LEFT OUTER JOIN DEPT
ON EMP.dept_id = DEPT.dept_id;
Output:
emp_id name dept_name
1 Riya HR
2 Pranav IT
3 Mansi NULL
2. RIGHT OUTER JOIN
Description: The RIGHT OUTER JOIN returns all records from the right table
(DEPT), and the matched records from the left table (EMP). The result is NULL from
the left side, when there is no match.
Syntax:
SELECT columns
FROM EMP
RIGHT OUTER JOIN DEPT
ON EMP.dept_id = DEPT.dept_id;
Example:
Description: The FULL OUTER JOIN returns all records when there is a match in
either left (EMP) or right (DEPT) table records. It returns NULL for records that do not
have a match in the other table.
Syntax:
SELECT columns
FROM EMP
FULL OUTER JOIN DEPT
ON EMP.dept_id = DEPT.dept_id;
Example:
SELECT EMP.emp_id, EMP.name, DEPT.dept_name
FROM EMP
FULL OUTER JOIN DEPT
ON EMP.dept_id = DEPT.dept_id;
Output:
emp_id name dept_name
1 Riya HR
2 Pranav IT
3 Mansi NULL
NULL NULL Finance
VII. Required Resources/apparatus/equipment with specifications
VIII. Procedure
1. Create tables for given application
2. Assign Primary key for created table
3. Join two or more tables
IX. Result(s)
……………………………………………………………………………………………
……………………………………………………………………………………………
……………………………………………………………………………………………
……………………………………………………………………………………………
X. Practical related questions (Provide space for answers)
Note: Below are a few sample questions for reference. Teacher must design more such
questions to ensure the achievement of identified CO.
1. Define Join. List types of Joins.
2. Describe outer join.
(Space for answer)
………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XI. Exercise
1. Display employee Nikhil’s employee number, name, department number, and department
location.
Experiment No 17: Create and manage Views for faster access on relations.
I. Practical Significance:
This practical will help students to understand Views, Sequences and Indexes used in
SQL. A view is a virtual table based on the result-set of an SQL statement. A view
contains rows and columns, just like a real table. The fields in a view are fields from
one or more real tables in the database. You can add SQL statements and functions to
a view and present the data as if the data were coming from one single table. A
sequence is a user-defined schema-bound object that generates a series of numeric
values. Indexes are used to retrieve data from the database more quickly than
otherwise. The users cannot see the indexes, they are just used to speed up
searches/queries.
Relevant LLO
Sr. Equipment Name with Broad Specifications
Number
No
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition, MySQL, SQLite, Oracle Live SQL etc.
VIII. Procedure
a. Write and execute query for view.
b. Write and execute query to insert, modify and delete records through views
c. Write and execute query to delete view.
d. Write and execute query for creating altering and dropping sequence.
e. Write and execute query for simple and composite index.
IX. Result(s)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
X. Practical related questions (Provide space for answers)
Note: Below are a few sample questions for reference. Teacher must design more
suchquestions so as to ensure the achievement of identified CO.
a. What are synonyms, write its syntax and advantages.
b. What is the difference between simple and composite index?
c. What are the disadvantages of views?
d. Write the syntax to delete view.
(Space for answer)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XI. Exercise:
1. Write output of the following queries.
i. Create view emp_view as select emp_no, enema, salary from emp;
ii. Update emp_view set e_name=’Jay’ where emp_no=101;
iii. Delete from emp_view where emp_no= 105;
iv. Drop view emp_view;
v. Modify location of dept_no of dept_view;
vi. Write output of following queries.
vii. Create simple index dept_simple-index on dept table.
viii. Create composite index dept_composite_index on dept table.
ix. Drop index dept_simple_index and dept_composite_index.
x. Create index raj on emp (empno, ename).
2 Write output of following queries.
a. Create sequence emp_sequence
Incremented by 2
Start with 1
Nomaxvalue
Nocycle
Cache 10;
b. Alter sequence emp_sequence
Incremented by 15
Max value 1000
Cycle
Cache20;
Marks Obtained
Process Product
Total (50)
Related (15) Related (35)
END IF;
END;
Relevant LLO
Sr.No Equipment Name with Broad Specifications
Number
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition,MySql,SQLite,Oracle Apex etc.
VIII. Procedure
Implement PL/SQL program based on the given problem
IX. Result(s)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
……
Practical related questions (Provide space for answers)
Note: Below are a few sample questions for reference. Teacher must design more
suchquestions to ensure the achievement of identified CO.
1. List conditional statement in PL/SQL.
2. Describe any three conditional statements in PL/SQL
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
X. Exercise
1. Write a PL/SQL program that checks if a given number is positive, and if it is, prints
"Number is positive".
2. Write a PL/SQL program that asks the user for their age and then prints “You can vote"
if they are over 18, and "You cannot vote" otherwise.
3. Write a PL/SQL program that asks the user for percentage and then assigns grades
based on the following conditions:
Distinction (>=75%)
First Class (>=60 and <75)
Second Class (>=45 and <60)
Pass Class (>=40 and <45)
Fail (<40)
2. https://www.tutorialspoint.com/plsql/plsql_conditional_control.htm
3. https://www.oreilly.com/library/view/oracle-plsql-
programming/9781449324445/ch04.html
XII. Assessment Scheme
Performance indicators Weightage
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
I. Practical Significance:
The PL/SQL loops are used to repeat the execution of one or more statements for a
specified number of times. These are also known as iterative control statements. The
iterative statement can be embedded in a PL/SQL procedure, function, or anonymous
block statement. In PL/SQL we have three different loop options to choose from when
we want to execute a statement repeatedly in our code block. They are:
a. Basic loop.
b. For loop
c. While loop
Relevant LLO
Sr.No Equipment Name with Broad Specifications
Number
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition,MySql,SQLite,Oracle Apex etc.
VIII. Procedure
Implement PL/SQL program based on the given problem
IX. Result(s)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
X. Practical related questions (Provide space for answers)
Note: Below are a few sample questions for reference. Teacher must design more
suchquestions to ensure the achievement of identified CO.
1. List Iterative statement in PL/SQL.
2. Write PL/SQL program using any one Iterative statement.
(Space for answer)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
Maharashtra State Board of Technical Education (‘K Scheme’) 94
DATABASE MANAGEMENT SYSTEM (313302)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
XI. Exercise
a. Write a PL/SQL program to display multiplication table of 5 using FOR loop.
b. Write a PL/SQL program to calculate factorial of 10 by using PL/SQL WHILE LOOP
statement.
c. Write a PL/SQL program to calculate the prime numbers between 1 to 50.
2. https://www.tutorialspoint.com/plsql/plsql
3. https://www.oreilly.com/library/view/oracle-plsql-
programming/9781449324445/ch04.html
4. PL/SQL WHILE Loop Tutorial (plsqltutorial.com)
5. https://www.ibm.com/pl/sql
XIII. Assessment Scheme
Performance indicators Weightage
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
I. Practical Significance: Sequential statements are used in PL/SQL help to control the order of
execution in PL/SQL code. The Case statement checks different conditions and executes
specific code based on those conditions. Goto jumps to a specific part of PL/SQL program,
continue skips to the next iteration of a loop. This practical allows students to implement
PL/SQL program using sequential control.
II. INDUSTRY / EMPLOYER EXPECTED OUTCOME:
To implement PL/SQL program with simple code structure using Sequential Control
III. COURSE LEVEL LEARNING OUTCOMES (COS):
CO4 - Implement PL/SQL codes for given application.
IV. LABORATORY LEARNING OUTCOME:
Implement PL/SQL program using Sequential Control.
V. Relevant Affective Domain related outcome(s)
a. Follow precautionary measures.
b. Follow installation steps.
c. Follow ethical practices.
VI. Relevant Theoretical Background
a. Case Statement
The PL/SQL CASE statement runs a series of actions depending on a selector, which can
be a variable, function, or expression. It functions similarly to an IF statement but uses the
keyword WHEN instead. The CASE statement checks conditions one by one from top to
bottom, executing the corresponding action when it finds a true condition, then moving to
the END CASE clause.
Syntax:
CASE selector
WHEN selector_value_1 THEN
statements_1
WHEN selector_value_1 THEN
statement_2
...
ELSE
Maharashtra State Board of Technical Education (‘K Scheme’) 100
DATABASE MANAGEMENT SYSTEM (313302)
else statements
END; CASE;
Example:
DECLARE
grade char(1) := 'A';
BEGIN
CASE grade
when 'A' then dbms_output.put_line('Excellent');
when 'B' then dbms_output.put_line('Very good');
when 'C' then dbms_output.put_line('Good');
when 'D' then dbms_output.put_line('Average');
when 'F' then dbms_output.put_line('Passed with Grace');
else dbms_output.put_line('Failed');
END CASE;
END;
2. CONTINUE
Explanation:
In PL/SQL, the CONTINUE statement allows you to skip the rest of the current iteration of
a loop and start the next iteration
Syntax:
CONTINUE;
Example:
DECLARE
counter NUMBER := 1;
BEGIN
WHILE counter <= 5 LOOP
IF counter = 3 THEN
CONTINUE; -- Skip the rest of the loop for counter = 3
END IF;
DBMS_OUTPUT.PUT_LINE('Counter: ' || counter);
counter := counter + 1;
Maharashtra State Board of Technical Education (‘K Scheme’) 101
DATABASE MANAGEMENT SYSTEM (313302)
END LOOP;
END;
In this example, the loop will print numbers from 1 to 5, but it will skip printing the number
3 due to the CONTINUE statement.
3. GOTO
In PL/SQL, the GOTO statement transfers control to a labeled statement within the same
block or subprogram.
Syntax:
GOTO label_name;
Example:
DECLARE
x NUMBER := 1;
BEGIN
<<start>>
DBMS_OUTPUT.PUT_LINE('Start');
GOTO end;
<<middle>>
DBMS_OUTPUT.PUT_LINE('Middle'); -- This line will be skipped
<<end>>
DBMS_OUTPUT.PUT_LINE('End');
END;
In this example, the program jumps directly from the start label to the end label, skipping the
middle label and its associated statement.
Relevant LLO
Sr.No Equipment Name with Broad Specifications
Number
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition,MySql,SQLite,Oracle Apex etc.
VIII. Procedure
1.Define the PL/SQL block structure
2.Write the control statements
3.Implement the logic for the given problem
IX. Result(s)
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
XI. Exercise
1. Write a PL/SQL program that calculates the sum of all even numbers between 1 and 10,
skipping odd numbers [Use CONTINUE statement]
2. Write a PL/SQL program that prints numbers from 1 to 10, but skips printing the
number 5 [Use GOTO statement]
3. Write a PL/SQL program that asks the user to input a number (1 for Monday, 2 for
Tuesday, ..., 7 for Sunday) and prints the corresponding day of the week.
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
I. Practical Significance:
A cursor is a pointer to this context area. PL/SQL controls the context area through a cursor.
A cursor holds the rows (one or more) returned by a SQL statement. The set of rows the cursor
holds is referred to as the active set. You can name a cursor so that it could be referred to in a
program to fetch and process the rows returned by the SQL statement, one at a time. There
are two types of cursors namely: Implicit cursors, Explicit cursors.
I. Implicit Cursors
An implicit cursor is generated by Oracle when DML statements such as INSERT, UPDATE,
and DELETE are executed. Oracle offers some attributes through which programmers can
perform operations on these cursors. Implicit cursors help to handle database transactions
without requiring to manually create cursors every time. The attributes offered by Oracle are
as follows:
a. %FOUND: This function returns a Boolean value of True,if INSERT, UPDATE, and
DELETE, affect single or multiple rows. Similarly, it returns True if any SELECT statement
also returns single or multiple rows. If neither of these conditions are met, the function will
return False.
b. %NOTFOUND: This attribute operates in reverse to its counterpart, %FOUND. If a DML
statement has not affected any rows or a SELECT statement does not return any results, then
the %NOTFOUND attribute will be evaluated as True. Alternatively, it will return False when
rows have been impacted by a DML statement or when the SELECT DML statement returns
at least one result.
c. %ISOPEN: Regarding Implicit cursors, Oracle shut off the cursor immediately following
the SQL statement’s execution, resulting in a False return value.
d. %ROWCOUNT: The function returns the rows affected by DML statements such as
INSERT, UPDATE, and DELETE. It can also provide the count of rows returned from
SELECT INTO statements in PL/SQL code.
Relevant LLO
Sr.No Equipment Name with Broad Specifications
Number
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition,MySql,SQLite,Oracle Apex etc.
VIII. Procedure
1.Write program in notepad, save the program with .sql extension.
2. Take the program to SQL command prompt.
3. Execute and check the program output.
IX. Result(s)
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
XI. Exercise
a. Write a PL/SQL program for displaying details of students studying in computer department
using cursors.
b. Write a PL/SQL program to print even number of records stored in the student table.
c. Write a PL/SQL program to display the number of items having price more than 10000 in
store table using cursors.
3. https://www.javatpoint.com/pl-sql-cursors
4. https://docs.oracle.com/en/database/other-databases/timesten/22.1/plsql-developer/use-
cursors-pl-sql-programs.html
5. https://traininginchennai.in/plsql_cursors.html
XIII. Assessment Scheme
Performance indicators Weightage
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
I. Practical Significance: Creating a PL/SQL program with exception handling using pre-
defined exceptions allows PL/SQL code to deal with unexpected errors or problems that
might happen while it runs. This makes PL/SQL program more reliable and prevents it from
crashing or giving wrong results when things go wrong unexpectedly. This practical allows
students to implement PL/SQL program based on pre-defined exceptions.
VIII. Procedure
1.Define the PL/SQL block structure
2.Implement the logic for the given problem
IX. Result(s)
……………………………………………………………………………………………………
……………………………………………………………………………………………………
Maharashtra State Board of Technical Education (‘K Scheme’) 112
DATABASE MANAGEMENT SYSTEM (313302)
……………………………………………………………………………………………………
X. Practical related questions (Provide space for answers)
Note: Below are a few sample questions for reference. Teacher must design more such
questions to ensure the achievement of identified CO.
1. Distinguish between user defined exception and predefined exception
2. Explain pre-defined exception with an example.
(Space for answer)
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
XI. Exercise
1. Write a PL/SQL program that asks the user to input two numbers and divide the first
number by the second. Handle the predefined exception for division by zero and
display an appropriate message if it occurs.
2. Write a PL/SQL program that retrieves the salary of an employee based on their
Maharashtra State Board of Technical Education (‘K Scheme’) 113
DATABASE MANAGEMENT SYSTEM (313302)
employee ID (emp_id). If the employee ID does not exist in the database, handle the
NO_DATA_FOUND exception and print a message saying, "Employee ID not found."
XII. References/Suggestions for further reading: include websites/links
1. https://www.youtube.com/watch?v=yGU4YfSSjdM
2. https://www.oracletutorial.com/plsql-tutorial/plsql-exception/
3. https://www.javatpoint.com/pl-sql-exception
XIII. Assessment Scheme
I. Practical Significance: PL/SQL allows you to define your own exceptions according to the
need of your program. A user-defined exception must be declared and then raised explicitly,
using either a RAISE statement or the procedure
DBMS_STANDARD.RAISE_APPLICATION_ERROR.
exp1 EXCEPTION;
exp2 EXCEPTION;
BEGIN
IF y=0 then
raise exp1;
ELSEIF y > x then
raise exp2;
ELSE
div_r:= x / y;
dbms_output.put_line('the result is '||div_r);
END IF;
EXCEPTION
WHEN exp1 THEN
dbms_output.put_line('Error');
dbms_output.put_line('division by zero not allowed');
WHEN exp2 THEN
dbms_output.put_line('Error');
dbms_output.put_line('y is greater than x please check the input');
END;
VII. Required Resources/apparatus/equipment with specifications
Relevant LLO
Sr.No Equipment Name with Broad Specifications
Number
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition, MySql,SQLite,Oracle Apex etc.
VIII. Procedure
1.Follow the rules while raising the exception.
2.Implement the logic for the given problem
IX. Result(s)
X. Practical related questions (Provide space for answers)
Maharashtra State Board of Technical Education (‘K Scheme’) 116
DATABASE MANAGEMENT SYSTEM (313302)
Note: Below are a few sample questions for reference. Teacher must design more such
questions to ensure the achievement of identified CO.
1. How to define the exception?
2. Create the Procedure with the help of user defined exception.
(Space for answer)
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
XI. Exercise
1. Write a PL/SQL program by using the user defined exception.
2. Write a PL/SQL program that asks for customer Id, when user enters invalid Id, the
exception Invalid-Id is raised.
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
I. Practical Significance: Procedures in PL/SQL is a named block of code that can be stored
in a database. Procedures accept input parameters, perform a specific task. They provide a
way to modularize code, enhance reusability, and promote efficient development practices.
This practical allows students to implement PL/SQL procedures and call them to perform
tasks.
II. INDUSTRY / EMPLOYER EXPECTED OUTCOME:
To implement PL/SQL procedure for modularity and to optimize performance, enhance
security
III. COURSE LEVEL LEARNING OUTCOMES (COS):
CO4 - Implement PL/SQL codes for given application.
IV. LABORATORY LEARNING OUTCOME:
Create Procedures and stored procedures for modularity.
V. Relevant Affective Domain related outcome(s)
a. Follow precautionary measures.
b. Follow installation steps.
c. Follow ethical practices.
VI. Relevant Theoretical Background
PL/SQL procedures, also known as stored procedures, are subprograms that can be called
to perform a specific action in a database. They can contain a series of SQL statements
and take parameters. PL/SQL procedures can be stored in a database and called by name
from an application.
Syntax for creating procedure:
CREATE [OR REPLACE] PROCEDURE procedure_name
[ (parameter [, parameter]) ]
IS
[declaration_section]
BEGIN
executable_section
[EXCEPTION
exception_section]
END [procedure_name];
Example:
CREATE OR REPLACE PROCEDURE greetings
AS
BEGIN
dbms_output.put_line('Hello World!');
END;
Calling a procedure:
BEGIN
greetings;
END;
In the above example, procedure is called by its name greetings
VII. Required Resources/apparatus/equipment with specifications
Relevant LLO
Sr.No Equipment Name with Broad Specifications
Number
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition,MySql,SQLite,Oracle Apex etc.
VIII. Procedure
1.Define the PL/SQL block structure for procedure
2.Implement the logic for the given problem
3. Call the stored procedure
IX. Result(s)
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
X. Practical related questions (Provide space for answers)
Note: Below are a few sample questions for reference. Teacher must design more such
questions to ensure the achievement of identified CO.
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
Function Body
The function body contains the actual logic of the function. It consists of a series of statements
that manipulate the input parameters and local variables to achieve the desired outcome. This
is where the magic happens, as developers can employ conditional statements, loops, and other
programming constructs to implement complex operations.
Return Statement
The return statement marks the end of the function and specifies the value that will be returned
to the caller. It is essential to ensure that the return type matches the one declared in the function
header.
SYNTAX:
FUNCTION function_name (parameter1 [IN | OUT | IN OUT] datatype, parameter2 [IN | OUT
| IN OUT] datatype, ...)
RETURN return_datatype
IS
-- Declaration section (optional)
variable1 datatype;
variable2 datatype;
...
BEGIN
-- Function body
-- SQL and PL/SQL statements
RETURN return_value;
EXCEPTION
-- Exception handling (optional)
WHEN exception_name1 THEN
-- Handle exception 1
WHEN exception_name2 THEN
-- Handle exception 2
...
END;
VII. Required Resources/apparatus/equipment with specifications
Relevant LLO
Sr.No Equipment Name with Broad Specifications
Number
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition,MySql,SQLite,Oracle Apex etc.
VIII. Procedure
1.Define the PL/SQL block structure
2.Implement the logic for the given problem
IX. Result(s)
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
X. Practical related questions (Provide space for answers)
Note: Below are a few sample questions for reference. Teacher must design more such
questions to ensure the achievement of identified CO.
1. What is the difference between Function and Procedure.
2. Write syntax for creating and replacing function.
(Space for answer)
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
XI. Exercise
1. Write PL/SQL function which will compute and return the maximum of two values.
2. Write PL/SQL function to calculate the factorial of given no.
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)
I. Practical Significance: PL/SQL triggers are named database objects stored in a database
that can be called automatically on the occurrence of a particular event. Triggers can be
used to automate database processes, enforce data integrity, and improve database
performance. This practical allows students to implement PL/SQL triggers for given
database.
[OF col_name]
ON table_name
[REFERENCING OLD AS o NEW AS n]
[FOR EACH ROW]
WHEN (condition)
DECLARE
Declaration-statements
BEGIN
Executable-statements
EXCEPTION
Exception-handling-statements
END;
VII. Required Resources/apparatus/equipment with specifications
Relevant LLO
Sr.No Equipment Name with Broad Specifications
Number
Computer system with all necessary components like; motherboard,
1 random access memory (RAM), read-only memory (ROM), internal hard All
disk drives, Mouse, Keyboard, and RDBMS applications such as Oracle
Express Edition,MySql,SQLite,Oracle Apex etc.
VIII. Procedure
1.Define the PL/SQL block structure
2.Implement the logic for the given problem
IX. Result(s)
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
Dated signature
Marks Obtained of Teacher
Process Product
Total (50)
Related (15) Related (35)