DBMS - File - FInal
DBMS - File - FInal
Samalkha
Computer Science & Engineering Department
Affiliated to
Practical No. 1
Problem Statement: Create a database and write the programs to carry out the
following operation:
Add, Delete and modify a record in the database.
Generate queries
Data Operations
List all the records of database in ascending order
Table Used:
create table college (C_ID number(3), S_NAME char(20), Gender char(1), Age nummber(2),Course char(6))
insert into college values('319', 'Mudit Gupta', 'M', '19', 'CSE')
insert into college values('123', 'Simran', 'F', '19', 'IT')
insert into college values('295', 'Nazim Mazumdar', 'M', '21', 'MBA')
insert into college values('294', 'John L Songate', 'M', '18', 'IT')
insert into college values('319', 'Rishabh Varshney', 'M', '19', 'CSE')
insert into college values('302', 'Syed Saquib', 'M', '18', 'CSE')
insert into college values('456', 'Yashika Tonk', 'F', '20', 'ECE')
Add, Delete and modify a record in the database.
Command: INSERT
Syntax-
insert into <table name> values (<expression1>,<expression2>)
Example-
insert into College values(‘789’,’Lucy David’,’F’,’21’,’MCA’ )
Output-
Command: UPDATE
Syntax-
update tablename set field=values where condition
Example-
update College set Course = ‘MCA’ where C_ID = ‘789’
Output-
After updating-
Command: DELETE
Syntax-
Delete from <table-name>
Example-
delete from College where Course = ‘MCA’
Output-
After Deletion-
Generate queries
Output-
select S_Name from College where C_Id BETWEEN 1000 and 1003
Output-
Data Operations
Command- AND
select S_Name, Course from College where C_ID = 319 and Age = 19
Output-
Command - OR
Output-
Command – NOT
Output-
\
List all the records of database in ascending order
Command – ORDER BY
select * from College order by AGE
Output-
Practical No. 2
Problem Statement: To perform various integrity constraints on relational database.
create table mg(S# number(3) primary key, Name char(20), Age number(2), check(age>18));
select * from mg;
Output:
Table creation:
create table Employee(E_ID number(5) primary key, Name char(20), Age number(2), Salary
number(6))
insert into Employee values('319', 'Mudit Gupta', '19', '45000')
insert into Employee values('123', 'Alex', '19', '40000')
insert into Employee values('321', 'James', '20', '35000')
insert into Employee values('456', 'Lucy', '21', '37000')
insert into Employee values('654', 'Peter', '20', '30000')
insert into Employee values('789', 'Parle', '21', '33000')
select * from Employee
Output-
Arithmetic Operations-
Example-
update Employee set Salary = Salary + 500
select * from Employee
Output-
Example-
Output-
Multiply Operator (*)
Example-
Example-
Output-
Relational Operations-
Example-
select * from Employee where Salary = 45150
Output-
Example-
select * from Employee where Salary < 55000
Output-
Example-
select * from Employee where Salary > 55000
Output-
Greater than or equal to (>=)
Example-
select * from Employee where Salary >= 50000
Output-
Example-
select * from Employee where Salary <= 60000
Output-
Not equal to (<>)
Example-
select * from Employee where Salary <> 49650
Output-
Group By Clause-
Example-
select count(Name), Age from Employee group by Age
Output-
Having Clause-
Example-
select count(Name), Age from Employee group by Age having count(E_ID)>=2
Output-
Example-
Output-
Practical No. 4
create view MultiProj as select Company.Name, Project.Project_Name from Company inner join
project on company.ssn = project.ssn where project.ssn in ( select SSN from project group by SSN
having Count(SSN)>1)
Output:
Output:
Practical No. 5
Problem Statement: Create a view to display details of employees not working on any
project.
create view NoProj as select Company.SSN ,Company.Name from Company left join Project on
company.ssn = project.ssn where project.ssn is NULL order by Company.ssn
Output:
Command:
Select emp.eid , emp.Name , emp.Salary , emp.DID, Dept.DID , Dept.D_Name from EMP full join Dept on
emp.DID = Dept.DID
Output:
Inner Join:
Select emp.eid , emp.Name ,emp.Salary, emp.DID, Dept.DID ,Dept.D_Name from emp inner join Dept on
emp.DID = Dept.DID
Output:
Left Join:
Select emp.eid , emp.Name ,emp.Salary, emp.DID, Dept.DID ,Dept.D_Name from emp left join Dept on
emp.DID = Dept.DID
Output:
Right Join:
Select emp.eid , emp.Name ,emp.Salary, emp.DID, Dept.DID ,Dept.D_Name from emp right join Dept on
emp.DID = Dept.DID
Output: