SQL> create table customer(cid
int,cname varchar2(20),age int,sex varchar2(10),dob varchar2(20),address
varchar2(20),phno int,email varchar2(20),anualincome varchar2(10),primary
key(cid));
Table created.
SQL> create table product(cid int,pid
int,pname varchar2(20),brandname varchar2(20),price int,quantity int,primary
key(cid,pid),foreign key(cid) references
customer);
Table created.
SQL>
insert into customer values('&cid','&cname','&age','&sex','&dob','&address','&phno','&email','
&anualincome');
Enter value for cid: 1
Enter value for cname: john
Enter value for age: 58
Enter value for sex: male
Enter value for dob: 5/7/55
Enter value for address: german
Enter value for phno: 8548547895
Enter value for email: john2@gmail.com
Enter value for anualincome: 15000
1 row created.
SQL> insert into product
values('&cid','&pid','&pname','&brandname','&price','&quantity');
Enter value for cid: 1
Enter value for pid: 1
Enter value for pname: x220
Enter value for brandname: sony
Enter value for price: 2500
Enter value for quantity: 5
1 row created.
SQL> select * from customer;
CID
CNAME AGE SEX
DOB ADDRESS PHNO EMAIL ANUALINCOM
---------- --------------------
---------- ----------
-------------------- -------------------- ---------- -----------------
1 john 58 male
5/7/55 german 8548547895 john2@gmail.com 15000
2 mac 47 male
1/9/65 japan 8547694857 mac33@gmail.com 14000
3 sam 21 male
1/7/91 greek 7894562175 sam2@yahoo.com 10000
SQL> select * from product;
CID
PID PNAME BRANDNAME PRICE
QUANTITY
------
------ ------------ --------------------- ----------
------------------
1 1 x220 sony 2500 5
2 2 xpro sony 10000 3
3 3 star 3 samsung 7000 1
SQL> select cname,pname from customer,product cid=pid and
quantity=5;
CNAME
PNAME
----------- ------------
John x220
SQL> select min(quantity) from
product;
QUANTITY
-----------------
1
SQL> select max (price) from product;
PRICE
-----------------
10000
No comments:
Post a Comment