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),annualincome varchar2(10),primary
key(cid));
Table created.
SQL>
insert into customer
values('&cid','&cname','&age','&sex','&dob','&address','&phno','&email','
&annualincome');
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 annualincome: 15000
1 row created.
SQL> select * from customer;
CID
CNAME AGE SEX
DOB ADDRESS PHNO EMAIL ANNUALINCOM
---------- --------------------
---------- ----------
-------------------- -------------------- ---------- -----------------
1 john 58 male
5/7/55 german 8548547895 john2@gmail.com 15000
2 mac 47 male
1/9/65 japan 854769485 mac33@gmail.com 14000
3 sam 21 male
1/7/91 greek 789456215 sam2@yahoo.com 10000
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 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 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 cid from customer union select cid from product;
CID
------
1
2
3
4
SQL>select cid from customer union all select cid from
product;
CID
------
1
2
3
4
1
2
3
4
No comments:
Post a Comment