Skip to content

Commit c0afaff

Browse files
committed
format
1 parent b37431c commit c0afaff

File tree

13 files changed

+1488
-811
lines changed

13 files changed

+1488
-811
lines changed

dbms/1.sql

Lines changed: 175 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,177 @@
1-
2-
create table client_master
3-
(
4-
client_no varchar(6),
5-
name varchar(20),
6-
city varchar(15),
7-
state varchar(15),
8-
pincode int(6),
9-
bal_due decimal(10,2)
1+
create table client_master (
2+
client_no varchar(6),
3+
name varchar(20),
4+
city varchar(15),
5+
state varchar(15),
6+
pincode int(6),
7+
bal_due decimal(10, 2)
108
);
11-
12-
create table product_master
13-
(
14-
product_no varchar(6),
15-
description varchar(20),
16-
profit_percent decimal(10,2),
17-
unit_measure varchar(15),
18-
qty_on_hand int(6),
19-
reorder_lvl int(6),
20-
sell_price decimal(10,2),
21-
cost_price decimal(10,2)
9+
create table product_master (
10+
product_no varchar(6),
11+
description varchar(20),
12+
profit_percent decimal(10, 2),
13+
unit_measure varchar(15),
14+
qty_on_hand int(6),
15+
reorder_lvl int(6),
16+
sell_price decimal(10, 2),
17+
cost_price decimal(10, 2)
2218
);
23-
24-
insert into client_master values('0001','Ivan','Bombay','Maharashtra',400054,15000),
25-
('0002','Vandana','Madras','Tamilnadu',780001,0),
26-
('0003','Pramada','Bombay','Maharashtra',400057,5000),
27-
('0004','Basu','Bombay','Maharashtra',400056,0),
28-
('0005','Ravi','Delhi','Delhi',100001,2000),
29-
('0006','Rukmini','Bombay','Maharashtra',400050,0);
30-
31-
insert into product_master values
32-
('P00001','1.44floppies',5,'piece',100,20,525,500),
33-
('P03453','Monitors',6,'piece',10,3,12000,11200),
34-
('P06734','Mouse',5,'piece',20,5,1050,500),
35-
('P07865','1.22 floppies',5,'piece',100,20,525,500),
36-
('P07868','Keyboards',2,'piece',10,3,3150,3050),
37-
('P07885','CD Drive',2.5,'piece',10,3,5250,5100),
38-
('P07965','540 HDD',4,'piece',10,3,8400,8000),
39-
('P07975','1.44 Drive',5,'piece',10,3,1050,1000),
40-
('P08865','1.22 Drive',5,'piece',2,3,1050,1000);
41-
42-
43-
44-
select name from client_master;
45-
select name,city from client_master;
46-
select description from product_master;
47-
select name from client_master where city='Bombay';
48-
select * from client_master where client_no='0001' or client_no='0002';
49-
select * from product_master where description='1.44 drive' or description='1.22 Drive';
50-
select * from product_master where sell_price>5000;
51-
select * from client_master where city='Bombay' or city='Delhi' or city='Madras';
52-
select * from product_master where sell_price>2000 and sell_price<=5000;
53-
select name,city,state from client_master where state!='Maharashtra';
19+
insert into client_master
20+
values(
21+
'0001',
22+
'Ivan',
23+
'Bombay',
24+
'Maharashtra',
25+
400054,
26+
15000
27+
),
28+
(
29+
'0002',
30+
'Vandana',
31+
'Madras',
32+
'Tamilnadu',
33+
780001,
34+
0
35+
),
36+
(
37+
'0003',
38+
'Pramada',
39+
'Bombay',
40+
'Maharashtra',
41+
400057,
42+
5000
43+
),
44+
(
45+
'0004',
46+
'Basu',
47+
'Bombay',
48+
'Maharashtra',
49+
400056,
50+
0
51+
),
52+
('0005', 'Ravi', 'Delhi', 'Delhi', 100001, 2000),
53+
(
54+
'0006',
55+
'Rukmini',
56+
'Bombay',
57+
'Maharashtra',
58+
400050,
59+
0
60+
);
61+
insert into product_master
62+
values (
63+
'P00001',
64+
'1.44floppies',
65+
5,
66+
'piece',
67+
100,
68+
20,
69+
525,
70+
500
71+
),
72+
(
73+
'P03453',
74+
'Monitors',
75+
6,
76+
'piece',
77+
10,
78+
3,
79+
12000,
80+
11200
81+
),
82+
('P06734', 'Mouse', 5, 'piece', 20, 5, 1050, 500),
83+
(
84+
'P07865',
85+
'1.22 floppies',
86+
5,
87+
'piece',
88+
100,
89+
20,
90+
525,
91+
500
92+
),
93+
(
94+
'P07868',
95+
'Keyboards',
96+
2,
97+
'piece',
98+
10,
99+
3,
100+
3150,
101+
3050
102+
),
103+
(
104+
'P07885',
105+
'CD Drive',
106+
2.5,
107+
'piece',
108+
10,
109+
3,
110+
5250,
111+
5100
112+
),
113+
(
114+
'P07965',
115+
'540 HDD',
116+
4,
117+
'piece',
118+
10,
119+
3,
120+
8400,
121+
8000
122+
),
123+
(
124+
'P07975',
125+
'1.44 Drive',
126+
5,
127+
'piece',
128+
10,
129+
3,
130+
1050,
131+
1000
132+
),
133+
(
134+
'P08865',
135+
'1.22 Drive',
136+
5,
137+
'piece',
138+
2,
139+
3,
140+
1050,
141+
1000
142+
);
143+
select name
144+
from client_master;
145+
select name,
146+
city
147+
from client_master;
148+
select description
149+
from product_master;
150+
select name
151+
from client_master
152+
where city = 'Bombay';
153+
select *
154+
from client_master
155+
where client_no = '0001'
156+
or client_no = '0002';
157+
select *
158+
from product_master
159+
where description = '1.44 drive'
160+
or description = '1.22 Drive';
161+
select *
162+
from product_master
163+
where sell_price > 5000;
164+
select *
165+
from client_master
166+
where city = 'Bombay'
167+
or city = 'Delhi'
168+
or city = 'Madras';
169+
select *
170+
from product_master
171+
where sell_price > 2000
172+
and sell_price <= 5000;
173+
select name,
174+
city,
175+
state
176+
from client_master
177+
where state != 'Maharashtra';

dbms/10.sql

Lines changed: 24 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,62 @@
1-
2-
31
-- 1. WAP in PL/SQL for addition of two numbers.
4-
52
sql
6-
DECLARE
7-
a INT := 10;
3+
DECLARE a INT := 10;
84
b INT := 20;
95
c INT;
10-
BEGIN
11-
c := a + b;
6+
BEGIN c := a + b;
127
DBMS_OUTPUT.PUT_LINE(c);
138
END;
14-
15-
169
-- 2. WAP in PL/SQL for addition of 1 to 100 numbers.
17-
1810
sql
19-
DECLARE
20-
a INT := 100;
11+
DECLARE a INT := 100;
2112
b INT := 1;
2213
c INT;
23-
BEGIN
24-
LOOP
25-
c := a + b;
14+
BEGIN LOOP c := a + b;
2615
b := b + 1;
2716
DBMS_OUTPUT.PUT_LINE(c);
28-
EXIT WHEN b > a;
17+
EXIT
18+
WHEN b > a;
2919
END LOOP;
3020
END;
31-
32-
3321
-- 3. WAP in PL/SQL to check the given number is even or odd.
34-
3522
sql
36-
DECLARE
37-
a INT := 2;
23+
DECLARE a INT := 2;
3824
b INT := 1;
3925
c INT;
40-
BEGIN
41-
c := a % b;
42-
IF c = 0 THEN
43-
DBMS_OUTPUT.PUT_LINE('Even');
44-
ELSE
45-
DBMS_OUTPUT.PUT_LINE('Odd');
26+
BEGIN c := a % b;
27+
IF c = 0 THEN DBMS_OUTPUT.PUT_LINE('Even');
28+
ELSE DBMS_OUTPUT.PUT_LINE('Odd');
4629
END IF;
4730
END;
48-
49-
5031
-- 4. WAP in PL/SQL to inverse a number, eg. Number 5639 when inverted must be display output 9365.
51-
5232
sql
53-
DECLARE
54-
a INT := 5639;
33+
DECLARE a INT := 5639;
5534
b INT := 0;
5635
c INT;
57-
BEGIN
58-
LOOP
59-
c := a % 10;
36+
BEGIN LOOP c := a % 10;
6037
b := b * 10 + c;
6138
a := a / 10;
6239
DBMS_OUTPUT.PUT_LINE(b);
63-
EXIT WHEN a = 0;
40+
EXIT
41+
WHEN a = 0;
6442
END LOOP;
6543
END;
66-
67-
6844
-- 5. WAP in PL/SQL for changing the price of product ‘P00001’ to 4000 if the price is less than 4000 in product_master table. The change is recorded in the old_price_table along with product_no and the date on which the price was changed last.
69-
7045
sql
71-
DECLARE
72-
a INT := 4000;
46+
DECLARE a INT := 4000;
7347
b INT;
7448
c INT;
7549
d VARCHAR2(20) := 'P00001';
7650
BEGIN
77-
SELECT price INTO b FROM product_master WHERE product_no = d;
51+
SELECT price INTO b
52+
FROM product_master
53+
WHERE product_no = d;
7854
IF b < a THEN
79-
UPDATE product_master SET price = a WHERE product_no = d;
80-
INSERT INTO old_price_table VALUES (d, b, SYSDATE);
55+
UPDATE product_master
56+
SET price = a
57+
WHERE product_no = d;
58+
INSERT INTO old_price_table
59+
VALUES (d, b, SYSDATE);
8160
END IF;
8261
END;
83-
84-
85-
-- <div style="page-break-after: always;"></div>
62+
-- <div style="page-break-after: always;"></div>

dbms/1t.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
Table 1: client_master table
22

33
| columnname | datatype | size |
4-
| --- | --- | --- |
5-
| client_no | varchar | 6 |
6-
| name | varchar | 20 |
7-
| city | varchar | 15 |
8-
| state | varchar | 15 |
9-
| pincode | int | 6 |
10-
| bal_due | decimal | 10,2 |
11-
4+
| ---------- | -------- | ---- |
5+
| client_no | varchar | 6 |
6+
| name | varchar | 20 |
7+
| city | varchar | 15 |
8+
| state | varchar | 15 |
9+
| pincode | int | 6 |
10+
| bal_due | decimal | 10,2 |
1211

1312
Table 2: product_master table
1413

15-
| columnname | datatype | size |
16-
| --- | --- | --- |
17-
| product_no | varchar | 6 |
18-
| description | varchar | 20 |
19-
| profit_percent | decimal | 10,2 |
20-
| unit_measure | varchar | 15 |
21-
| qty_on_hand | int | 6 |
22-
| reorder_lvl | int | 6 |
23-
| sell_price | decimal | 10,2 |
24-
| cost_price | decimal | 10,2 |
14+
| columnname | datatype | size |
15+
| -------------- | -------- | ---- |
16+
| product_no | varchar | 6 |
17+
| description | varchar | 20 |
18+
| profit_percent | decimal | 10,2 |
19+
| unit_measure | varchar | 15 |
20+
| qty_on_hand | int | 6 |
21+
| reorder_lvl | int | 6 |
22+
| sell_price | decimal | 10,2 |
23+
| cost_price | decimal | 10,2 |

0 commit comments

Comments
 (0)