0% found this document useful (0 votes)
1 views14 pages

dbms

The document outlines SQL queries demonstrating logical, arithmetic, and relational operations on database tables. It includes examples of creating tables, inserting data, and using various SQL commands such as SELECT, UPDATE, and INSERT with different constraints. Additionally, it covers integrity constraints like domain, entity, key, and referential integrity in relational databases.

Uploaded by

Lv Chn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views14 pages

dbms

The document outlines SQL queries demonstrating logical, arithmetic, and relational operations on database tables. It includes examples of creating tables, inserting data, and using various SQL commands such as SELECT, UPDATE, and INSERT with different constraints. Additionally, it covers integrity constraints like domain, entity, key, and referential integrity in relational databases.

Uploaded by

Lv Chn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy