0% found this document useful (0 votes)
35 views

Notepad

The document creates tables to store salesman, customer, and orders data. It inserts data into the tables, sets primary and foreign keys, deletes and updates some order records, and performs various queries on the tables.

Uploaded by

Sharad Dhumal
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Notepad

The document creates tables to store salesman, customer, and orders data. It inserts data into the tables, sets primary and foreign keys, deletes and updates some order records, and performs various queries on the tables.

Uploaded by

Sharad Dhumal
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Create table Salesman(S_id number(5) primary key not NULL,Name Varchar2(15),City

Varchar2(15),Commission FLOAT);
insert into salesman values(5001,'James Hooq','New Yark',0.15);
insert into salesman values(5002,'Nail Knite','Paris',0.13);
insert into salesman values(5005,'Pit Alex','London',0.11);
insert into salesman values(5006,'Mc Lyon','Paris',0.14);
insert into salesman values(5003,'Lauson Hen',' ',0.12);
insert into salesman values(5007,'Paul Adam','Rome',0.13);

Select * from salesman;

alter table salesman ADD PRIMARY KEY(salesman.s_id);

Create table Customer(Cust_id number(5) primary key not null,Cust_name


varchar2(20),City Varchar2(20),Grade Number(4),S_ID NUMBER(5),FOREIGN KEY(S_ID)
REFERENCES salesman(S_ID));

insert into Customer values(3002,'Nick Ramando','New Yark',100,5001);


insert into Customer values(3005,'Graham zusi','California',200,5002);
insert into Customer values(3001,'Brad Guzan','London','' ,'');
insert into Customer values(3004,'Fabian Johns','Paris',300,5006);
insert into Customer values(3007,''Brad Davis','New Yark',200,5001);
insert into Customer values(3009,'Geoff camero','Berlin',100,'');
insert into Customer values(3008,'Julian Green','London',300,5002);
insert into Customer values(3003,'Jozy Altidor','Moncow',200,5007);

CREATE TABLE Orders(order_no number(5) primary key,purch_amt FLOAT,orderdate


date,Cust_id NUMBER(6),S_ID number(5),FOREIGN KEY(Cust_id) REFERENCES
customer(Cust_id),FOREIGN KEY(S_ID)REFERENCES salesman(S_ID));

insert into Orders values(70001,150.5,TO_DATE('2016-10-05','yy-mm-dd'),3005,5002);


insert into Orders values(70009,270.65,TO_DATE('2016-09-10','yy-mm-dd'),3001,'');
insert into Orders values(70002,65.26,TO_DATE('2016-10-05','yy-mm-dd'),3002,5001);
insert into Orders values(70004,110.5,TO_DATE('2016-08-17','yy-mm-dd'),3009,'');
insert into Orders values(70007,948.5,TO_DATE('2016-09-10','yy-mm-dd'),3005,5002);
insert into Orders values(70005,2400.6,TO_DATE('2016-07-27','yy-mm-dd'),3007,5001);
insert into Orders values(70008,5760,TO_DATE('2016-09-10','yy-mm-dd'),3002,5001);
insert into Orders values(70010,1983.43,TO_DATE('2016-10-10','yy-mm-
dd'),3004,5006);
insert into Orders values(70003,2480.4,TO_DATE('2016-10-10','yy-mm-dd'),3009,'');
insert into Orders values(70012,250.45,TO_DATE('2016-06-27','yy-mm-dd'),3008,5002);
insert into Orders values(70011,75.29,TO_DATE('2016-08-17','yy-mm-dd'),3003,5007);

Delete Record using order_id=====

delete from Orders where orders.order_no=70001;


delete from Orders where orders.order_no=70005;
delete from Orders where orders.order_no=70004;
delete from Orders where orders.order_no=70007;
delete from Orders where orders.order_no=70002;
===============
Update table Values
===============
update orders set S_ID=5005 where order_no=70009;
update orders set S_ID=5003 where order_no=70004;
update orders set S_ID=5003 where order_no=70003;
==============
Create table nobel_win(year number(5)primary key,subject varchar2(20),winner
varchar2(20),country varchar2(20),category varchar2(20));
select * from Customer where city='New York'or grade>100;
select * from Customer where city='New York'or Not grade>100;
select * from salesman where commission between 0.12 and 0.14;
select * from salesman where (commission>0.12 and Commission<0.14);
select * from salesman where commission between 0.10 and 0.12;
select * from salesman where(commission>0.10 and Commission<0.12);
select * from customer where cust_name like'%n';
select * from salesman where name like'N__l%';
select * from customer where grade is null;
select sum(purch_amt) from orders;
select count(S_ID) from orders;
select count(Distinct(S_ID)) from orders;
select city,max(grade) from Customer group by city;
select Cust_id,max(purch_amt) from orders Group by Cust_id;

You might also like