Practical No.
3
Problem Statement : Write SQL queries using Logical Operators
create table Companyy(E_ID number(10),E_Name char(20),E_Salary number(20));
Insert into Companyy values('106','Williams','24000');
Select*from Companyy
Output:-
1)AND
Select E_Name from Companyy where E_Id=101 and E_Salary=42000;
Output:-
2)OR
Select E_Name from Companyy where E_Id =101 or E_Salary=41000;
Output:-
3)NOT
Select E_Name from Companyy where NOT E_Id = 101;
Output:-
5)BETWEEN
Select E_Name from Companyy where E_Id BETWEEN 101 and 104;
Output:-
6)IN
Select E_Name from Companyy where E_Id In ('101','104');
Output:-
Practical No. 4
Problem Statement : Create a database and perform the following
operations:-
Create table Employee(E_Id number(5) primary key, Name char(20), Age number(2),Salary
number(6));
Insert into Employee values (5,'Williams',24,80000);
Select * from Employee
Arithmetic Operations-
1)Add Operator (+)
Update Employee set Salary = Salary + 1000;
Output:-
2)Subtract Operator (-)
Update Employee set Salary = Salary - 1000;
Output-
3)Multiply Operator (*)
Update Employee set Salary = Salary*0.5;
Output:-
6)Divide Operator (/)
Update Employee set Salary = Salary/2;
Output:-
Relational Operations-
1)Equal Operator (=)
Select * from Employee where Salary = 20000;
Output:-
2)Less than Operator (<)
select * from Employee where Salary<20000;
Output:-
3)Less than Operator (<=)
select * from Employee where Salary<=20000;
Output:-
4)Greater than Operator (>)
select * from Employee where Salary>10000;
Output:-
5)Greater than Operator (>=)
select * from Employee where Salary>=10000;
Output:-
6) Not equal to (<>)
select * from Employee where Salary <> 20000;
Output:-
Group By Clause-
select count(E_ID), Salary from Employee Group by Salary;
Output:-
Having Clause-
select count(E_ID), Salary from Employee Group by Salary having count(E_ID) >= 2;
Output-
Like predicate for pattern matching in database-
select E_ID, Name, Salary from Employee where Name like 'N%';
Output-
Practical No. 5
Problem Statement : To perform various integrity constraints on
relational database.
create table Students(S_Id number(5) primary key, Name char(25), Age number(3));
insert into Students values('003','Peter','21');
Select * from Students;
1)Domain Constraints-
insert into Students values('004','Peter','Twenty');
Output-
2)Entity integrity constraints-
insert into Students values(' ' , ‘Peter', '21');
Output-
3)Key constraints-
insert into Students values('001','Peter','21');
Output-
4)Referential Integrity constraints-
Table 1-
Create table Dept(D_No number(2) primary key, D_Name char(25));
Insert into Dept values('1', 'CSE');
Select * from Dept;
Table 2-
Create table Student12(S_Id number(5) primary key, Name char(20), Age number(2), D_No
number(2) references Dept(D_No));
Insert into Student12 values('001',Bhawna,'20','1');
Select * from Student12;
Insert into Student12 values('004','Peter','23','4');
INDEX
S.No. Practical Name Date Signature