-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathText-Dump-2
653 lines (505 loc) · 33.1 KB
/
Text-Dump-2
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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
SQL> SELECT FIRST_NAME, MID_NAME, LAST_NAME
2 FROM EMPLOYEE
3 WHERE SALARY>25000;
FIRST_NAME MI LAST_NAME
--------------- -- ---------------
Doug E Gilbert
Joyce PAN
Frankin T Wong
Jennifer S Wallace
Johny B Smith
Ramesh K Narayan
James E Borg
SQL> SELECT FIRST_NAME, MID_NAME, LAST_NAME
2 FROM EMPLOYEE
3 WHERE SALARY>25000 AND SEX='M';
FIRST_NAME MI LAST_NAME
--------------- -- ---------------
Doug E Gilbert
Frankin T Wong
Johny B Smith
Ramesh K Narayan
James E Borg
SQL> SELECT FIRST_NAME, MID_NAME, LAST_NAME
2 FROM EMPLOYEE
3 WHERE SALARY>25000 AND SEX='F';
FIRST_NAME MI LAST_NAME
--------------- -- ---------------
Joyce PAN
Jennifer S Wallace
SQL> SELECT FIRST_NAME, MID_NAME, LAST_NAME
2 FROM EMPLOYEE
3 WHERE SALARY BETWEEN 30000 AND 70000;
FIRST_NAME MI LAST_NAME
--------------- -- ---------------
Joyce PAN
Frankin T Wong
Jennifer S Wallace
Johny B Smith
Ramesh K Narayan
James E Borg
6 rows selected.
SQL> SELECT FIRST_NAME, LAST_NAME
2 FROM EMPLOYEE
3 WHERE SUPERVISOR_SSN IS NULL;
FIRST_NAME LAST_NAME
--------------- ---------------
Doug Gilbert
Joyce PAN
SQL> DESCRIBE EMPLOYEE
Name Null? Type
----------------------------------------- -------- ----------------------------
FIRST_NAME NOT NULL VARCHAR2(15)
MID_NAME CHAR(2)
LAST_NAME NOT NULL VARCHAR2(15)
SSN_NUMBER NOT NULL CHAR(9)
BIRTHDAY DATE
ADDRESS VARCHAR2(50)
SEX CHAR(1)
SALARY NUMBER(7)
SUPERVISOR_SSN CHAR(9)
DEPT_NO NUMBER(5)
SQL> SELECT FIRST_NAME, LAST_NAME, BIRTHDAY
2 FROM EMPLOYEE;
FIRST_NAME LAST_NAME BIRTHDAY
--------------- --------------- ---------
Doug Gilbert 09-JUN-60
Joyce PAN 07-FEB-78
Frankin Wong 08-DEC-45
Jennifer Wallace 20-JUN-31
Johny Smith 09-JAN-55
Ramesh Narayan 15-SEP-52
Joyce English 31-JUL-62
James Borg 10-NOV-27
Alicia Zelaya 19-JUL-58
Ahmad Jabbar 29-MAR-59
10 rows selected.
SQL> SELECT FIRST_NAME, LAST_NAME
2 FROM EMPLOYEE
3 WHERE BIRTHDAY<'01-JAN-78';
FIRST_NAME LAST_NAME
--------------- ---------------
Doug Gilbert
Frankin Wong
Jennifer Wallace
Johny Smith
Ramesh Narayan
Joyce English
James Borg
Alicia Zelaya
Ahmad Jabbar
9 rows selected.
SQL> SELECT FIRST_NAME, LAST_NAME, BIRTHDAY
2 FROM EMPLOYEE
3 WHERE BIRTHDAY<'01-JAN-78';
FIRST_NAME LAST_NAME BIRTHDAY
--------------- --------------- ---------
Doug Gilbert 09-JUN-60
Frankin Wong 08-DEC-45
Jennifer Wallace 20-JUN-31
Johny Smith 09-JAN-55
Ramesh Narayan 15-SEP-52
Joyce English 31-JUL-62
James Borg 10-NOV-27
Alicia Zelaya 19-JUL-58
Ahmad Jabbar 29-MAR-59
9 rows selected.
SQL> SELECT FIRST_NAME
2 FROM EMPLOYEE
3 WHERE FIRST_NAME LIKE 'J____';
FIRST_NAME
---------------
Joyce
Johny
Joyce
James
SQL> SELECT FIRST_NAME, MID_NAME, LAST_NAME
2 FROM EMPLOYEE
3 WHERE MID_NAME IS NULL;
no rows selected
SQL> SELECT FIRST_NAME, MID_NAME, LAST_NAME
2 FROM EMPLOYEE;
FIRST_NAME MI LAST_NAME
--------------- -- ---------------
Doug E Gilbert
Joyce PAN
Frankin T Wong
Jennifer S Wallace
Johny B Smith
Ramesh K Narayan
Joyce A English
James E Borg
Alicia J Zelaya
Ahmad V Jabbar
10 rows selected.
SQL> SELECT FIRST_NAME, MID_NAME, LAST_NAME
2 FROM EMPLOYEE
3 WHERE MID_NAME IS NULL;
no rows selected
SQL> SELECT FIRST_NAME, LAST_NAME, ADDRESS
2 FROM EMPLOYEE
3 WHERE SEX='M' AND ADDRESS LIKE '%HOUSTON%';
no rows selected
SQL> SELECT FIRST_NAME, LAST_NAME, ADDRESS
2 FROM EMPLOYEE;
FIRST_NAME LAST_NAME
--------------- ---------------
ADDRESS
--------------------------------------------------
Doug Gilbert
11 S 59 E, Salt Lake City, UT
Joyce PAN
35 S 18 E, Salt Lake City, UT
Frankin Wong
638 Voss, Houston, TX
FIRST_NAME LAST_NAME
--------------- ---------------
ADDRESS
--------------------------------------------------
Jennifer Wallace
291 Berry, Bellaire, TX
Johny Smith
731 Fondren, Houston, TX
Ramesh Narayan
975 Fire Oak, Humble, TX
FIRST_NAME LAST_NAME
--------------- ---------------
ADDRESS
--------------------------------------------------
Joyce English
5631 Rice, Houston, TX
James Borg
450 Stone, Houston, TX
Alicia Zelaya
3321 Castle, Spring, TX
FIRST_NAME LAST_NAME
--------------- ---------------
ADDRESS
--------------------------------------------------
Ahmad Jabbar
980 Dallas, Houston, TX
10 rows selected.
SQL> SELECT FIRST_NAME, LAST_NAME, ADDRESS
2 FROM EMPLOYEE
3 WHERE SEX='M' AND ADDRESS LIKE '%Houston%';
FIRST_NAME LAST_NAME
--------------- ---------------
ADDRESS
--------------------------------------------------
Frankin Wong
638 Voss, Houston, TX
Johny Smith
731 Fondren, Houston, TX
James Borg
450 Stone, Houston, TX
FIRST_NAME LAST_NAME
--------------- ---------------
ADDRESS
--------------------------------------------------
Ahmad Jabbar
980 Dallas, Houston, TX
SQL> DESCRIBE DEPARTMENT
Name Null? Type
----------------------------------------- -------- ----------------------------
DEPT_NAME VARCHAR2(15)
DEPT_NO NUMBER(5)
MANAGERSSN CHAR(9)
MANAGESTARTDATE DATE
CONTACT_NO NUMBER(10)
SQL> SELECT DEPT_NAME
2 FROM DEPARTMENT
3 WHERE DEPT_NAME LIKE '%e';
DEPT_NAME
---------------
Manufacture
Finance
SQL> SELECT FIRST_NAME, SUPERVISOR_SSN
2 FROM EMPLOYEE
3 WHERE SUPERVISOR_SSN IN (554433221, 333445555);
FIRST_NAME SUPERVISO
--------------- ---------
Frankin 554433221
Jennifer 554433221
Johny 333445555
Ramesh 333445555
Joyce 333445555
SQL> SELECT UPPER(DEPT_NAME)
2 FROM DEPARTMENT;
UPPER(DEPT_NAME
---------------
MANUFACTURE
ADMINISTRATION
HEADQUARTER
FINANCE
RESEARCH
SQL> SELECT LOWER(DEPT_NAME)
2 FROM DEPARTMENT;
LOWER(DEPT_NAME
---------------
manufacture
administration
headquarter
finance
research
SQL> SELECT TABLE_NAME FROM USER_TABLES;
TABLE_NAME
------------------------------
DEPARTMENT
DEPT_LOC
PATIENT
PROJECT
EMPLOYEE
SQL> DESC EMPLOYEE
Name Null? Type
----------------------------------------- -------- ----------------------------
FIRST_NAME NOT NULL VARCHAR2(15)
MID_NAME CHAR(2)
LAST_NAME NOT NULL VARCHAR2(15)
SSN_NUMBER NOT NULL CHAR(9)
BIRTHDAY DATE
ADDRESS VARCHAR2(50)
SEX CHAR(1)
SALARY NUMBER(7)
SUPERVISOR_SSN CHAR(9)
DEPT_NO NUMBER(5)
SQL> DESC PROJECT
Name Null? Type
----------------------------------------- -------- ----------------------------
PROJECT_NAME VARCHAR2(15)
PROJECT_NUMBER NUMBER(5)
PROJECT_LOCATION VARCHAR2(15)
DEPARTMENT_NUMBER NUMBER(5)
SQL> DROP TABLE PATIENT;
Table dropped.
SQL> DESC DEPARTMENT
Name Null? Type
----------------------------------------- -------- ----------------------------
DEPT_NAME VARCHAR2(15)
DEPT_NO NUMBER(5)
MANAGERSSN CHAR(9)
MANAGESTARTDATE DATE
CONTACT_NO NUMBER(10)
SQL> SELECT ADD_MONTHS(MANAGESTARTDATE, 2)
2 FROM DEPARTMENT;
ADD_MONTH
---------
19-AUG-71
04-MAR-99
22-NOV-55
01-MAR-85
22-JUL-78
SQL> SELECT ROUND((MONTHS_BETWEEN(SYSDATE, BIRTHDAY)/12), 2)
2 FROM EMPLOYEE;
ROUND((MONTHS_BETWEEN(SYSDATE,BIRTHDAY)/12),2)
----------------------------------------------
54.7
37.04
69.2
83.67
60.12
62.43
52.56
87.28
56.59
55.9
10 rows selected.
SQL> SELECT FIRST_NAME, ROUND((MONTHS_BETWEEN(SYSDATE, BIRTHDAY)/12), 2)
2 FROM EMPLOYEE;
FIRST_NAME ROUND((MONTHS_BETWEEN(SYSDATE,BIRTHDAY)/12),2)
--------------- ----------------------------------------------
Doug 54.7
Joyce 37.04
Frankin 69.2
Jennifer 83.67
Johny 60.12
Ramesh 62.43
Joyce 52.56
James 87.28
Alicia 56.59
Ahmad 55.9
10 rows selected.
SQL> SELECT LAST_DAY(MANAGESTARTDATE)
2 FROM DEPARTMENT;
LAST_DAY(
---------
30-JUN-71
31-JAN-99
30-SEP-55
31-JAN-85
31-MAY-78
SQL> SELECT MANAGESTARTDATE,LAST_DAY(MANAGESTARTDATE)
2 FROM DEPARTMENT;
MANAGESTA LAST_DAY(
--------- ---------
19-JUN-71 30-JUN-71
04-JAN-99 31-JAN-99
22-SEP-55 30-SEP-55
01-JAN-85 31-JAN-85
22-MAY-78 31-MAY-78
SQL> SELECT MANAGESTARTDATE+1, MANAGESTARTDATE-1
2 FROM DEPARTMENT;
MANAGESTA MANAGESTA
--------- ---------
20-JUN-71 18-JUN-71
05-JAN-99 03-JAN-99
23-SEP-55 21-SEP-55
02-JAN-85 31-DEC-84
23-MAY-78 21-MAY-78
SQL> SELECT SUBSTR('RAMANA',1,4)
2 FROM DUAL;
SUBS
----
RAMA
SQL> SELECT SUBSTR('RAMANA',2,4)
2 FROM DUAL;
SUBS
----
AMAN
SQL> SELECT SUBSTR(ADDRESS, 5, 7)
2 FROM EMPLOYEE;
SUBSTR(
-------
59 E,
18 E,
Voss, H
Berry,
Fondren
Fire Oa
Rice,
Stone,
Castle
Dallas,
10 rows selected.
SQL> SELECT REPLACE('RAMANA', 'NA', 'SRI'
2 )
3 FROM DUAL;
REPLACE
-------
RAMASRI
SQL> SELECT LENGTH(DEPT_NAME)
2 FROM DEPARTMENT;
LENGTH(DEPT_NAME)
-----------------
11
14
11
7
8
SQL> SELECT TO_CHAR (SYSDATE, 'DDth "OF" fmmonth yyyy')
2 from dual;
TO_CHAR(SYSDATE,'DDTH"
----------------------
21ST OF february 2015
SQL> SELECT TO_CHAR (SYSDATE, 'DDth fmmonth yyyy')
2 from dual;
TO_CHAR(SYSDATE,'DDT
--------------------
21ST february 2015
SQL> SELECT ADD_MONTHS(SYSDATE, 8)
2 FROM DUAL;
ADD_MONTH
---------
21-OCT-15
SQL> SELECT NEXT_DAY(SYSDATE, 'Friday')
2 FROM DUAL;
NEXT_DAY(
---------
27-FEB-15
SQL> DESC PROJECT
Name Null? Type
----------------------------------------- -------- ----------------------------
PROJECT_NAME VARCHAR2(15)
PROJECT_NUMBER NUMBER(5)
PROJECT_LOCATION VARCHAR2(15)
DEPARTMENT_NUMBER NUMBER(5)
SQL> SELECT RPAD(PROJECT_LOCATION,LENGTH(PROJECT_LOCATION)+3, '***')
2 FROM PROJECT;
RPAD(PROJECT_LOCATION,LENGTH(PROJECT_LOCATION)+3,'***')
--------------------------------------------------------------------------------
Houston***
Salt Lake City***
Houston***
Bellaire***
Sugarland***
Salt Lake City***
New York***
Stafford***
Chicago***
San Francisco***
10 rows selected.
SQL> SELECT PROJECT_NAME
2 FROM PROJECT;
PROJECT_NAME
---------------
project valuesA
project valuesB
project valuesC
project valuesD
project valuesE
project valuesF
project valuesG
project valuesH
project valuesI
project valuesJ
10 rows selected.
SQL> UPDATE PROJECT SET PROJECT_NAME='projectA'
2 WHERE PROJECT_NAME LIKE 'project valuesA';
1 row updated.
SQL> UPDATE PROJECT SET PROJECT_NAME='projectB'
2 WHERE PROJECT_NAME LIKE 'project valuesB';
1 row updated.
SQL> UPDATE PROJECT SET PROJECT_NAME='projectC'
2 WHERE PROJECT_NAME LIKE 'project valuesC';
1 row updated.
SQL> UPDATE PROJECT SET PROJECT_NAME='projectD'
2 WHERE PROJECT_NAME LIKE 'project valuesD';
1 row updated.
SQL> UPDATE PROJECT SET PROJECT_NAME='projectE'
2 WHERE PROJECT_NAME LIKE 'project valuesE';
1 row updated.
SQL> UPDATE PROJECT SET PROJECT_NAME='projectF'
2 WHERE PROJECT_NAME LIKE 'project valuesF';
1 row updated.
SQL> UPDATE PROJECT SET PROJECT_NAME='projectG'
2 WHERE PROJECT_NAME LIKE 'project valuesG';
1 row updated.
SQL> UPDATE PROJECT SET PROJECT_NAME='projectH'
2 WHERE PROJECT_NAME LIKE 'project valuesH';
1 row updated.
SQL> UPDATE PROJECT SET PROJECT_NAME='projectI'
2 WHERE PROJECT_NAME LIKE 'project valuesI';
1 row updated.
SQL> UPDATE PROJECT SET PROJECT_NAME='projectJ'
2 WHERE PROJECT_NAME LIKE 'project valuesJ';
1 row updated.
SQL> SELECT SUBSTR(PROJECT_NAME, 7, 1)
2 FROM PROJECT;
S
-
t
t
t
t
t
t
t
t
t
t
10 rows selected.
SQL> SELECT SUBSTR(PROJECT_NAME, 8, 1)
2 FROM PROJECT;
S
-
A
B
C
D
E
F
G
H
I
J
10 rows selected.
SQL> SPOOL OFF