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
* from product where pname like ‘%x220%’;
CID
PID PNAME BRANDNAME PRICE
QUANTITY
------
------ ------------ --------------------- ----------
------------------
1 1 x220 sony 2500 5
SQL>select
* from product where pname like ‘%g’;
CID
PID PNAME BRANDNAME PRICE
QUANTITY
------
------ ------------ --------------------- ----------
------------------
3 3 star 3 samsung 7000 1
SQL>select
* from product where pname like ‘s%’;
CID
PID PNAME BRANDNAME PRICE
QUANTITY
------
------ ------------ --------------------- ----------
------------------
1 1 x220 sony 2500 5
2 2 xpro sony 10000 3
SQL>select
* from product order by cid asc;
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
* from product order by cid desc;
CID
PID PNAME BRANDNAME PRICE
QUANTITY
------
------ ------------ --------------------- ----------
------------------
3 3 star 3 samsung 7000 1
2 2 xpro sony 10000 3
1 1 x220 sony 2500 5
No comments:
Post a Comment