-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic_cmd.txt
334 lines (288 loc) · 11.5 KB
/
basic_cmd.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
MariaDB [(none)]> use practice
Database changed
MariaDB [practice]> show tables;
Empty set (0.001 sec)
MariaDB [practice]> create table student(usn varchar(10),name varchar(20),sem integer,sec char(1));
Query OK, 0 rows affected (0.325 sec)
MariaDB [practice]> show tables;
+--------------------+
| Tables_in_practice |
+--------------------+
| student |
+--------------------+
1 row in set (0.001 sec)
MariaDB [practice]> desc student;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| usn | varchar(10) | YES | | NULL | |
| name | varchar(20) | YES | | NULL | |
| sem | int(11) | YES | | NULL | |
| sec | char(1) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
4 rows in set (0.010 sec)
MariaDB [practice]> insert into student values('4MH17CS113','VARSHINI',5,'C');
Query OK, 1 row affected (0.138 sec)
MariaDB [practice]> insert into student values('4MH17CS115','VIDYASHREE',5,'A');
Query OK, 1 row affected (0.029 sec)
MariaDB [practice]> insert into student values('4MH17CS093','SONALI',5,'B');
Query OK, 1 row affected (0.123 sec)
MariaDB [practice]> insert into student values('4MH17CS118','YUKTHA',5,'B');
Query OK, 1 row affected (0.153 sec)
MariaDB [practice]> insert into student values('4MH17CS119','YUKTHI',5,'C');
Query OK, 1 row affected (0.135 sec)
MariaDB [practice]> select * from student;
+------------+------------+------+------+
| usn | name | sem | sec |
+------------+------------+------+------+
| 4MH17CS113 | VARSHINI | 5 | C |
| 4MH17CS115 | VIDYASHREE | 5 | A |
| 4MH17CS093 | SONALI | 5 | B |
| 4MH17CS118 | YUKTHA | 5 | B |
| 4MH17CS119 | YUKTHI | 5 | C |
+------------+------------+------+------+
5 rows in set (0.001 sec)
MariaDB [practice]> select name from student;
+------------+
| name |
+------------+
| VARSHINI |
| VIDYASHREE |
| SONALI |
| YUKTHA |
| YUKTHI |
+------------+
5 rows in set (0.001 sec)
MariaDB [practice]> select usn,
-> name from student
-> ;
+------------+------------+
| usn | name |
+------------+------------+
| 4MH17CS113 | VARSHINI |
| 4MH17CS115 | VIDYASHREE |
| 4MH17CS093 | SONALI |
| 4MH17CS118 | YUKTHA |
| 4MH17CS119 | YUKTHI |
+------------+------------+
5 rows in set (0.001 sec)
MariaDB [practice]> select * from student where sec='c';
+------------+----------+------+------+
| usn | name | sem | sec |
+------------+----------+------+------+
| 4MH17CS113 | VARSHINI | 5 | C |
| 4MH17CS119 | YUKTHI | 5 | C |
+------------+----------+------+------+
2 rows in set (0.001 sec)
MariaDB [practice]> select * from student where sec!='a';
+------------+----------+------+------+
| usn | name | sem | sec |
+------------+----------+------+------+
| 4MH17CS113 | VARSHINI | 5 | C |
| 4MH17CS093 | SONALI | 5 | B |
| 4MH17CS118 | YUKTHA | 5 | B |
| 4MH17CS119 | YUKTHI | 5 | C |
+------------+----------+------+------+
4 rows in set (0.001 sec)
MariaDB [practice]> select count(*) from student;
+----------+
| count(*) |
+----------+
| 5 |
+----------+
1 row in set (0.001 sec)
MariaDB [practice]> select count(*) from student where sec='a';
+----------+
| count(*) |
+----------+
| 1 |
+----------+
1 row in set (0.001 sec)
MariaDB [practice]> update student
-> set sem=7 where
-> sec='B';
Query OK, 2 rows affected (0.076 sec)
Rows matched: 2 Changed: 2 Warnings: 0
MariaDB [practice]> select * from student;
+------------+------------+------+------+
| usn | name | sem | sec |
+------------+------------+------+------+
| 4MH17CS113 | VARSHINI | 5 | C |
| 4MH17CS115 | VIDYASHREE | 5 | A |
| 4MH17CS093 | SONALI | 7 | B |
| 4MH17CS118 | YUKTHA | 7 | B |
| 4MH17CS119 | YUKTHI | 5 | C |
+------------+------------+------+------+
5 rows in set (0.000 sec)
MariaDB [practice]> alter table student change sec
-> section char(5);
Query OK, 5 rows affected (0.881 sec)
Records: 5 Duplicates: 0 Warnings: 0
MariaDB [practice]> alter table student change sem
-> semester int;
Query OK, 0 rows affected (0.035 sec)
Records: 0 Duplicates: 0 Warnings: 0
MariaDB [practice]> desc student;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| usn | varchar(10) | YES | | NULL | |
| name | varchar(20) | YES | | NULL | |
| semester | int(11) | YES | | NULL | |
| section | char(5) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
4 rows in set (0.007 sec)
MariaDB [practice]> alter table student add fee float;
Query OK, 0 rows affected (0.340 sec)
Records: 0 Duplicates: 0 Warnings: 0
MariaDB [practice]> select * from student;
+------------+------------+----------+---------+------+
| usn | name | semester | section | fee |
+------------+------------+----------+---------+------+
| 4MH17CS113 | VARSHINI | 5 | C | NULL |
| 4MH17CS115 | VIDYASHREE | 5 | A | NULL |
| 4MH17CS093 | SONALI | 7 | B | NULL |
| 4MH17CS118 | YUKTHA | 7 | B | NULL |
| 4MH17CS119 | YUKTHI | 5 | C | NULL |
+------------+------------+----------+---------+------+
5 rows in set (0.001 sec)
MariaDB [practice]> update student set fee = 50000;
Query OK, 5 rows affected (0.382 sec)
Rows matched: 5 Changed: 5 Warnings: 0
MariaDB [practice]> select * from student;
+------------+------------+----------+---------+-------+
| usn | name | semester | section | fee |
+------------+------------+----------+---------+-------+
| 4MH17CS113 | VARSHINI | 5 | C | 50000 |
| 4MH17CS115 | VIDYASHREE | 5 | A | 50000 |
| 4MH17CS093 | SONALI | 7 | B | 50000 |
| 4MH17CS118 | YUKTHA | 7 | B | 50000 |
| 4MH17CS119 | YUKTHI | 5 | C | 50000 |
+------------+------------+----------+---------+-------+
5 rows in set (0.001 sec)
MariaDB [practice]> update student set fee = 68000 where usn='4MH17CS119';
Query OK, 1 row affected (0.028 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [practice]> update student set fee = 56000 where usn='4MH17CS113';
Query OK, 1 row affected (0.049 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [practice]> update student set fee = 67000 where name='VIDYASHREE';
Query OK, 1 row affected (0.125 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [practice]> select * from student;
+------------+------------+----------+---------+-------+
| usn | name | semester | section | fee |
+------------+------------+----------+---------+-------+
| 4MH17CS113 | VARSHINI | 5 | C | 56000 |
| 4MH17CS115 | VIDYASHREE | 5 | A | 67000 |
| 4MH17CS093 | SONALI | 7 | B | 50000 |
| 4MH17CS118 | YUKTHA | 7 | B | 50000 |
| 4MH17CS119 | YUKTHI | 5 | C | 68000 |
+------------+------------+----------+---------+-------+
5 rows in set (0.001 sec)
MariaDB [practice]> select sum(fee) from student;
+----------+
| sum(fee) |
+----------+
| 291000 |
+----------+
1 row in set (0.000 sec)
MariaDB [practice]> select max(fee) from student;
+----------+
| max(fee) |
+----------+
| 68000 |
+----------+
1 row in set (0.001 sec)
MariaDB [practice]> select min(fee) from student;
+----------+
| min(fee) |
+----------+
| 50000 |
+----------+
1 row in set (0.001 sec)
MariaDB [practice]> select avg(fee) from student;
+----------+
| avg(fee) |
+----------+
| 58200 |
+----------+
1 row in set (0.001 sec)
MariaDB [practice]> select sum(fee),max(fee),min(fee),avg(fee) from student;
+----------+----------+----------+----------+
| sum(fee) | max(fee) | min(fee) | avg(fee) |
+----------+----------+----------+----------+
| 291000 | 68000 | 50000 | 58200 |
+----------+----------+----------+----------+
1 row in set (0.001 sec)
MariaDB [practice]> select sum(fee) as sum_of_fee from student;
+------------+
| sum_of_fee |
+------------+
| 291000 |
+------------+
1 row in set (0.001 sec)
MariaDB [practice]> select * from student order by name desc;
+------------+------------+----------+---------+-------+
| usn | name | semester | section | fee |
+------------+------------+----------+---------+-------+
| 4MH17CS119 | YUKTHI | 5 | C | 68000 |
| 4MH17CS118 | YUKTHA | 7 | B | 50000 |
| 4MH17CS115 | VIDYASHREE | 5 | A | 67000 |
| 4MH17CS113 | VARSHINI | 5 | C | 56000 |
| 4MH17CS093 | SONALI | 7 | B | 50000 |
+------------+------------+----------+---------+-------+
5 rows in set (0.001 sec)
MariaDB [practice]> select * from student order by name asc;
+------------+------------+----------+---------+-------+
| usn | name | semester | section | fee |
+------------+------------+----------+---------+-------+
| 4MH17CS093 | SONALI | 7 | B | 50000 |
| 4MH17CS113 | VARSHINI | 5 | C | 56000 |
| 4MH17CS115 | VIDYASHREE | 5 | A | 67000 |
| 4MH17CS118 | YUKTHA | 7 | B | 50000 |
| 4MH17CS119 | YUKTHI | 5 | C | 68000 |
+------------+------------+----------+---------+-------+
5 rows in set (0.001 sec)
MariaDB [practice]> alter table student drop fee;
Query OK, 0 rows affected (0.606 sec)
Records: 0 Duplicates: 0 Warnings: 0
MariaDB [practice]> select * from student;
+------------+------------+----------+---------+
| usn | name | semester | section |
+------------+------------+----------+---------+
| 4MH17CS113 | VARSHINI | 5 | C |
| 4MH17CS115 | VIDYASHREE | 5 | A |
| 4MH17CS093 | SONALI | 7 | B |
| 4MH17CS118 | YUKTHA | 7 | B |
| 4MH17CS119 | YUKTHI | 5 | C |
+------------+------------+----------+---------+
5 rows in set (0.001 sec)
MariaDB [practice]> delete from student where section='B';
Query OK, 2 rows affected (0.122 sec)
MariaDB [practice]> select * from student;
+------------+------------+----------+---------+
| usn | name | semester | section |
+------------+------------+----------+---------+
| 4MH17CS113 | VARSHINI | 5 | C |
| 4MH17CS115 | VIDYASHREE | 5 | A |
| 4MH17CS119 | YUKTHI | 5 | C |
+------------+------------+----------+---------+
3 rows in set (0.001 sec)
MariaDB [practice]> delete from student;
Query OK, 3 rows affected (0.128 sec)
MariaDB [practice]> select * from student;
Empty set (0.001 sec)
MariaDB [practice]> show tables;
+--------------------+
| Tables_in_practice |
+--------------------+
| student |
+--------------------+
1 row in set (0.001 sec)
MariaDB [practice]> drop table student;
Query OK, 0 rows affected (0.265 sec)
MariaDB [practice]> show tables;
Empty set (0.001 sec)
MariaDB [practice]> select * from student;
ERROR 1146 (42S02): Table 'practice.student' doesn't exist