SQL
SQL
SQL
SQL> ed omi
SQL> get omi.sql;
1 create table clientmaster
2 ( client_no varchar2(6),
3 name varchar2(20),
4 address1 varchar2(30),
5 address2 varchar2(30),
6 city varchar2(15),
7 pincode number(8),
8 state varchar2(15),
9 bal_due number(10,2));
10 create table productmaster
11 ( product_n0 varchar2(6),
12 description varchar2(15),
13 profit_percent number(4,2),
14 unit_measure varchar2(10),
15 qty_on_hand number(8),
16 reorder_lvl number(8),
17 sell_price number(8,2),
18 cost_price number(8,2));
19 create table salesman
20 (salesman_no varchar2(6),
21 salesman_name varchar2(20),
22 address1 varchar2(30),
23 address2 varchar2(30),
24 city varchar2(20),
25 puncode number(8),
26 state varchar2(20),
27 sal_amt number(8,2),
28 tgt_to_get number(6,2),
29 ytd_sales number(6,2),
30* remarks varchar(60));
31
SQL> insert into clientmaster values
('&client_no','&name','&address1','&address2','&city',&pincode,'&state',&
bal_due);
Enter value for client_no: c0001
Enter value for name: ivan bayross
Enter value for address1: g-444
Enter value for address2: east of kailash
Enter value for city: mumbai
Enter value for pincode: 400054
Enter value for state: maharashtra
Enter value for bal_due: 15000
old
1: insert into clientmaster values
('&client_no','&name','&address1','&address2','&city',&pincode,'&state',&
bal_due)
new
1: insert into clientmaster values ('c0001','ivan bayross','g444','east of kailash','mumbai',400054,'maharashtra',15000)
1 row created.
SQL> /
Enter value for client_no: c0002
Enter value for name: mamta mauzumdar
Enter value for address1: a-450
Enter value for address2: subhash nagar
Enter value for city: madaras
Enter value for pincode: 78001
Enter value for state: tamil nadu
Enter value for bal_due: 0
old
1: insert into clientmaster values
('&client_no','&name','&address1','&address2','&city',&pincode,'&state',&
bal_due)
new
1: insert into clientmaster values ('c0002 ','mamta mauzumdar','a450','subhash nagar','madaras',78001,'tamil nadu',0)
1 row created.
SQL> /
Enter value for client_no: c0003
Enter value for name: chaya bankar
Enter value for address1: g-54
Enter value for address2: tilak nagar
Enter value for city: mumbai
Enter value for pincode: 400057
Enter value for state: maharashtra
Enter value for bal_due: 5000
old
1: insert into clientmaster values
('&client_no','&name','&address1','&address2','&city',&pincode,'&state',&
bal_due)
new
1: insert into clientmaster values ('c0003','chaya bankar','g54','tilak nagar','mumbai',400057,'maharashtra',5000)
1 row created.
SQL> /
Enter value for client_no: c0004
Enter value for name: ashiwni
Enter value for address1: d145/3
Enter value for address2: garhi
Enter value for city: mumbai
Enter value for pincode: 400057
Enter value for state: maharashtra
Enter value for bal_due: 0
old
1: insert into clientmaster values
('&client_no','&name','&address1','&address2','&city',&pincode,'&state',&
bal_due)
new
1: insert into clientmaster values ('c0004
','ashiwni','d145/3','garhi','mumbai',400057,'maharashtra',0)
1 row created.
a-450
madaras
CLIENT NAME
ADDRESS1
------ -------------------- -----------------------------ADDRESS2
CITY
PINCODE STATE
------------------------------ --------------- ---------- --------------BAL_DUE
---------c0003 chaya bankar
tilak nagar
5000
g-54
mumbai
400057 maharashtra
c0004
garhi
d145/3
mumbai
400057 maharashtra
ashiwni
CLIENT NAME
ADDRESS1
------ -------------------- -----------------------------ADDRESS2
CITY
PINCODE STATE
------------------------------ --------------- ---------- --------------BAL_DUE
---------0
SQL> insert into productmaster values
('&product_n0','&description',&profit_percent,'&unit_measure',&qty_on_han
d,&reorder_lvl,&sell_price,&cost_price);
Enter value for product_n0: p0001
Enter value for description: t-shirts
Enter value for profit_percent: 5
Enter value for unit_measure: piece
Enter value for qty_on_hand: 200
Enter value for reorder_lvl: 50
Enter value for sell_price: 350
Enter value for cost_price: 250
old
1: insert into productmaster values
('&product_n0','&description',&profit_percent,'&unit_measure',&qty_on_han
d,&reorder_lvl,&sell_price,&cost_price)
new
1: insert into productmaster values ('p0001','tshirts',5,'piece',200,50,350,250)
1 row created.
SQL> /
Enter value for product_n0: p0345
Enter value for description: shirts
Enter value for profit_percent: 6
Enter value for unit_measure: piece
Enter value for qty_on_hand: 150
Enter value for reorder_lvl: 50
Enter value for sell_price: 500
Enter value for cost_price: 350
old
1: insert into productmaster values
('&product_n0','&description',&profit_percent,'&unit_measure',&qty_on_han
d,&reorder_lvl,&sell_price,&cost_price)
new
1: insert into productmaster values
('p0345','shirts',6,'piece',150,50,500,350)
1 row created.
SQL> /
Enter value for product_n0: p06734
Enter value for description: cotton jeans
Enter value for profit_percent: 5
Enter value for unit_measure: piece
Enter value for qty_on_hand: 100
Enter value for reorder_lvl: 20
Enter value for sell_price: 600
Enter value for cost_price: 450
old
1: insert into productmaster values
('&product_n0','&description',&profit_percent,'&unit_measure',&qty_on_han
d,&reorder_lvl,&sell_price,&cost_price)
new
1: insert into productmaster values ('p06734','cotton
jeans',5,'piece',100,20,600,450)
1 row created.
SQL> /
Enter value for product_n0: p07865
Enter value for description: jeans
Enter value for profit_percent: 5
Enter value for unit_measure: piece
Enter value for qty_on_hand: 100
Enter value for reorder_lvl: 20
Enter value for sell_price: 750
Enter value for cost_price: 500
old
1: insert into productmaster values
('&product_n0','&description',&profit_percent,'&unit_measure',&qty_on_han
d,&reorder_lvl,&sell_price,&cost_price)
new
1: insert into productmaster values
('p07865','jeans',5,'piece',100,20,750,500)
1 row created.
shirts
500
6 piece
150
50
5 piece
100
20
350
PRODUC DESCRIPTION
PROFIT_PERCENT UNIT_MEASU QTY_ON_HAND REORDER_LVL
------ --------------- -------------- ---------- ----------- ----------SELL_PRICE COST_PRICE
---------- ---------p07865 jeans
5 piece
100
20
750
500
SQL> insert into salesman values
('&salesman_no','&salesman_name','&address1','&address2','&city',&puncode
,'&state',&sal_amt,&tgt_to_get,&ytd_sales,'&remarks');
Enter value for salesman_no: s0001
Enter value for salesman_name: aman
Enter value for address1: a/14
Enter value for address2: worli
Enter value for city: mumbai
Enter value for puncode: 400002
Enter value for state: maharashtra
Enter value for sal_amt: 3000
Enter value for tgt_to_get: 1000
Enter value for ytd_sales: 50
Enter value for remarks: good
old
1: insert into salesman values
('&salesman_no','&salesman_name','&address1','&address2','&city',&puncode
,'&state',&sal_amt,&tgt_to_get,&ytd_sales,'&remarks')
new
1: insert into salesman values
('s0001','aman','a/14','worli','mumbai',400002,'maharashtra',3000,1000,50
,'good')
1 row created.
SQL> /
Enter value
Enter value
Enter value
Enter value
Enter value
for
for
for
for
for
salesman_no: s0002
salesman_name: omkar
address1: 65
address2: nariman
city: mumbai
nariman
maharashtra
good
mumbai
3000
400001
200
100
SALESM SALESMAN_NAME
ADDRESS1
------ -------------------- -----------------------------ADDRESS2
CITY
PUNCODE
------------------------------ -------------------- ---------STATE
SAL_AMT TGT_TO_GET YTD_SALES
-------------------- ---------- ---------- ---------REMARKS
-----------------------------------------------------------s0003 raj
p-7
bandra
mumbai
400032
maharashtra
3000
200
100
good
SALESM SALESMAN_NAME
ADDRESS1
------ -------------------- -----------------------------ADDRESS2
CITY
PUNCODE
------------------------------ -------------------- ---------STATE
SAL_AMT TGT_TO_GET YTD_SALES
-------------------- ---------- ---------- ---------REMARKS
-----------------------------------------------------------s000
ashish
a/5
juhu
mumbai
400044
maharashta
3500
200
150
good
SQL> select name from clientmaster;
NAME
-------------------ivan bayross
mamta mauzumdar
chaya bankar
ashiwni
SQL> select * from clientmaster;
CLIENT NAME
ADDRESS1
------ -------------------- -----------------------------ADDRESS2
CITY
PINCODE STATE
------------------------------ --------------- ---------- --------------BAL_DUE
---------c0001 ivan bayross
g-444
east of kailash
mumbai
400054 maharashtra
15000
a-450
madaras
CLIENT NAME
ADDRESS1
------ -------------------- -----------------------------ADDRESS2
CITY
PINCODE STATE
------------------------------ --------------- ---------- --------------BAL_DUE
---------c0003 chaya bankar
tilak nagar
5000
g-54
mumbai
400057 maharashtra
c0004
garhi
d145/3
mumbai
400057 maharashtra
ashiwni
CLIENT NAME
ADDRESS1
------ -------------------- -----------------------------ADDRESS2
CITY
PINCODE STATE
------------------------------ --------------- ---------- --------------BAL_DUE
---------0
SQL> select name city state from clientmaster;
select name city state from clientmaster
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected
SQL> select name,city,state from clientmaster;
NAME
-------------------ivan bayross
mamta mauzumdar
chaya bankar
ashiwni
CITY
--------------mumbai
madaras
mumbai
mumbai
STATE
--------------maharashtra
tamil nadu
maharashtra
maharashtra
*
ERROR at line 1:
ORA-00904: invalid column name
SQL> select product_n0 from productmaster;
PRODUC
-----p0001
p0345
p06734
p07865
SQL> select name from clientmaster where city=mumbai;
select name from clientmaster where city=mumbai
*
ERROR at line 1:
ORA-00904: invalid column name
SQL> select name from clientmaster where city= mumbai;
select name from clientmaster where city= mumbai
*
ERROR at line 1:
ORA-00904: invalid column name
SQL> select name from clientmaster where city='mumba';
no rows selected
SQL> select name from clientmaster where city='mumbai';
NAME
-------------------ivan bayross
chaya bankar
ashiwni
SQL> select name from salesman where sal_amt='3000';
select name from salesman where sal_amt='3000'
*
ERROR at line 1:
ORA-00904: invalid column name
SQL> select name from salesman where sal_amt=3000;
select name from salesman where sal_amt=3000
*
ERROR at line 1:
ORA-00904: invalid column name
a-450
madaras
CLIENT NAME
ADDRESS1
------ -------------------- -----------------------------ADDRESS2
CITY
PINCODE STATE
g-54
mumbai
400057 maharashtra
c0004
garhi
d145/3
mumbai
400057 maharashtra
ashiwni
CLIENT NAME
ADDRESS1
------ -------------------- -----------------------------ADDRESS2
CITY
PINCODE STATE
------------------------------ --------------- ---------- --------------BAL_DUE
---------0
SQL> update clientmaster SET pincode = 140525 where client_no='c0001';
1 row updated.
SQL> update clientmaster SET bal_due = 1000 where client_no='c0002';
0 rows updated.
SQL> update clientmaster set bal_due = 1000 where client_n0='c0001';
update clientmaster set bal_due = 1000 where client_n0='c0001'
*
ERROR at line 1:
ORA-00904: invalid column name
SQL> update clientmaster SET bal_due = 1000 where client_no='c0001';
1 row updated.
SQL> update productmaster SET cost_price=950 where description='jeans';
1 row updated.
SQL> update * productmaster SET city='pune';
update * productmaster SET city='pune'
*
ERROR at line 1:
ORA-00903: invalid table name
SQL> update productmaster SET city='Pune';
update productmaster SET city='Pune'
*
ERROR at line 1:
a-450
madaras
CLIENT NAME
ADDRESS1
------ -------------------- -----------------------------ADDRESS2
CITY
PINCODE STATE
------------------------------ --------------- ---------- --------------BAL_DUE
---------c0003 chaya bankar
tilak nagar
5000
g-54
mumbai
400057 maharashtra
c0004
garhi
d145/3
mumbai
400057 maharashtra
ashiwni
CLIENT NAME
ADDRESS1
------ -------------------- -----------------------------ADDRESS2
CITY
PINCODE STATE
------------------------------ --------------- ---------- --------------BAL_DUE
---------0
SQL> select * from productmaster;
PRODUC DESCRIPTION
PROFIT_PERCENT UNIT_MEASU QTY_ON_HAND REORDER_LVL
------ --------------- -------------- ---------- ----------- ----------SELL_PRICE COST_PRICE
---------- ---------p0001 t-shirts
5 piece
200
50
350
250
p0345
shirts
500
6 piece
150
50
5 piece
100
20
350
PRODUC DESCRIPTION
PROFIT_PERCENT UNIT_MEASU QTY_ON_HAND REORDER_LVL
------ --------------- -------------- ---------- ----------- ----------SELL_PRICE COST_PRICE
---------- ---------p07865 jeans
5 piece
100
20
750
950
SQL> select * from salesman;\
2
SQL>
SQL> select * from salesman;
SALESM SALESMAN_NAME
ADDRESS1
------ -------------------- -----------------------------ADDRESS2
CITY
PUNCODE
------------------------------ -------------------- ---------STATE
SAL_AMT TGT_TO_GET YTD_SALES
-------------------- ---------- ---------- ---------REMARKS
-----------------------------------------------------------s0001 aman
a/14
worli
pune
400002
maharashtra
3000
1000
50
good
SALESM SALESMAN_NAME
ADDRESS1
------ -------------------- -----------------------------ADDRESS2
CITY
PUNCODE
------------------------------ -------------------- ---------STATE
SAL_AMT TGT_TO_GET YTD_SALES
-------------------- ---------- ---------- ---------REMARKS
-----------------------------------------------------------s0002 omkar
65
nariman
pune
400001
maharashtra
3000
200
100
good
SALESM SALESMAN_NAME
ADDRESS1
------ -------------------- -----------------------------ADDRESS2
CITY
PUNCODE
------------------------------ -------------------- ---------STATE
SAL_AMT TGT_TO_GET YTD_SALES
g-444
mumbai
140525 maharashtra
g-54
mumbai
400057 maharashtra
CLIENT NAME
ADDRESS1
------ -------------------- -----------------------------ADDRESS2
CITY
PINCODE STATE
------------------------------ --------------- ---------- --------------BAL_DUE
---------c0004
garhi
ashiwni
d145/3
mumbai
400057 maharashtra
0
SQL> select * from productmaster;
PRODUC DESCRIPTION
PROFIT_PERCENT UNIT_MEASU QTY_ON_HAND REORDER_LVL
------ --------------- -------------- ---------- ----------- ----------SELL_PRICE COST_PRICE
---------- ---------p0001 t-shirts
5 piece
200
50
350
250
p0345
shirts
500
6 piece
150
350
50
g-54
mumbai
400057 maharashtra
CLIENT NAME
ADDRESS1
------ -------------------- -----------------------------ADDRESS2
CITY
PINCODE STATE
------------------------------ --------------- ---------- --------------BAL_DUE TELEPHONE
---------- ---------c0004
garhi
ashiwni
d145/3
mumbai
400057 maharashtra
0
SQL> select * salesman;
select * salesman
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected
SQL> select * from productmaster;
PRODUC DESCRIPTION
PROFIT_PERCENT UNIT_MEASU QTY_ON_HAND REORDER_LVL
------ --------------- -------------- ---------- ----------- ----------SELL_PRICE COST_PRICE
---------- ---------p0001 t-shirts
5 piece
200
50
350
250
p0345
shirts
500
6 piece
350
150
50