You are on page 1of 9

SQL PAT

SAI KIRAN T V
22BPS1172
Question 1
SQL> create table Shop_Sai1172 (s_num varchar2(10),s_Name
varchar2(15),sLocation varchar2(15));
SQL> create table Shopkeeper_Sai1172 (sID int primary
key,sName varchar2(15),m_SALARY int,sno varchar2(10),dob
date);
SQL> create table Customer_Sai1172 (cID varchar2(10),cName
varchar2(15),sno varchar2(10),sID int references
Shopkeeper_Sai1172);
SQL> insert into shopkeeper_Sai1172 values
(11,'Ramesh',30000,'P12','16-JUN-1990');

1 row created.

SQL> insert into shopkeeper_Sai1172 values


(22,'Shital',35000,'P14','18-MAR-1990');

1 row created.

SQL> insert into shopkeeper_Sai1172 values


(33,'Reena',29000,'P30','21-MAR-1986');
1 row created.

SQL> insert into shopkeeper_Sai1172 values


(44,'Aditya',40500,'P12','10-MAY-1991');

1 row created.

SQL> insert into shopkeeper_Sai1172 values


(55,'Alex',70000,'P22','23-APR-2001');

1 row created.

SQL> insert into shopkeeper_Sai1172 values


(66,'Rony',45000,'P22','17-SEP-2002');

1 row created.

SQL> insert into shopkeeper_Sai1172 values


(77,'Ronit',70000,'P30','24-OCT-2001');

1 row created.
SQL> insert into shopkeeper_Sai1172 values
(88,'Vinay',81000,'P30','10-MAY-1995');

1 row created.

SQL> select * from Shopkeeper_Sai1172;

SQL> insert into shop_Sai1172 values ('P12','Eternity','Chennai');

1 row created.

SQL> insert into shop_Sai1172 values ('P14','Empress','Chennai');

1 row created.

SQL> insert into shop_Sai1172 values ('P22','Compact','Mumbai');

1 row created.

SQL> insert into shop_Sai1172 values ('P30','Abide','Delhi');

1 row created.
SQL> select * from Shop_Sai1172;

SQL> insert into customer_Sai1172


values('C12','Sheena','P12',11);

1 row created.

SQL> insert into customer_Sai1172 values('C14','Reena','P14',22);

1 row created.

SQL> insert into customer_Sai1172


values('C15','Madhan','P14',22);

1 row created.

SQL> insert into customer_Sai1172


values('C16','Prabhat','P30',77);

1 row created.
SQL> insert into customer_Sai1172
values('C17','Sharat','P30',33);

1 row created.

SQL> insert into customer_Sai1172 values('C18','Nilesh','P12',44);

1 row created.

SQL> insert into customer_Sai1172


values('C19','Mukesh','P30',33);

1 row created.

SQL> select * from customer_Sai1172;


Question 2
SQL> select sID,S_Name from shopkeeper_Sai1172 s inner join
shop_Sai1172 a on s.sno=a.S_num;
Question 3
Query->SQL> select sName from Shopkeeper_Sai1172 where
m_SALARY< (select avg(m_SALARY) from Shopkeeper_Sai1172
where sno='P30');

Question 4
SQL> select cName,sName from Customer_Sai1172 c inner join
shopkeeper_Sai1172 s on s.sno=c.sno;
Question 5
SQL> select s_name from shop_Sai1172 where s_num not in
(select sno from customer_Sai1172);

You might also like