-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAll JOINS.TXT
306 lines (260 loc) · 164 KB
/
All JOINS.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
SQL> SELECT E.ENAME,E.EMPNO,M.ENAME,M.EMPNO
2 FROM EMP E, EMP M
3 WHERE E.MGR=M.EMPNO(+);
ENAME EMPNO ENAME EMPNO
---------- ---------- ---------- ----------
SMITH 7369 FORD 7902
ALLEN 7499 BLAKE 7698
WARD 7521 BLAKE 7698
JONES 7566 KING 7839
MARTIN 7654 BLAKE 7698
BLAKE 7698 KING 7839
CLARK 7782 KING 7839
SCOTT 7788 JONES 7566
KING 7839
TURNER 7844 BLAKE 7698
ADAMS 7876 SCOTT 7788
JAMES 7900 BLAKE 7698
FORD 7902 JONES 7566
MILLER 7934 CLARK 7782
14 rows selected.
SQL> SELECT * FROM EMP;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
14 rows selected.
SQL> ED
Wrote file afiedt.buf
1* SELECT * FROM EMP
SQL> SELECT E.ENAME,E.EMPNO,M.ENAME,M.EMPNO
2 FROM EMP E, EMP M
3 WHERE E.MGR=M.EMPNO;
ENAME EMPNO ENAME EMPNO
---------- ---------- ---------- ----------
SMITH 7369 FORD 7902
ALLEN 7499 BLAKE 7698
WARD 7521 BLAKE 7698
JONES 7566 KING 7839
MARTIN 7654 BLAKE 7698
BLAKE 7698 KING 7839
CLARK 7782 KING 7839
SCOTT 7788 JONES 7566
TURNER 7844 BLAKE 7698
ADAMS 7876 SCOTT 7788
JAMES 7900 BLAKE 7698
FORD 7902 JONES 7566
MILLER 7934 CLARK 7782
13 rows selected.
SQL> ED
Wrote file afiedt.buf
1 SELECT E.ENAME,E.EMPNO,M.ENAME,M.EMPNO
2 FROM EMP E, EMP M
3* WHERE E.MGR(+)=M.EMPNO
SQL> /
ENAME EMPNO ENAME EMPNO
---------- ---------- ---------- ----------
SMITH 7369
ALLEN 7499
WARD 7521
FORD 7902 JONES 7566
SCOTT 7788 JONES 7566
MARTIN 7654
TURNER 7844 BLAKE 7698
ALLEN 7499 BLAKE 7698
WARD 7521 BLAKE 7698
JAMES 7900 BLAKE 7698
MARTIN 7654 BLAKE 7698
MILLER 7934 CLARK 7782
ADAMS 7876 SCOTT 7788
BLAKE 7698 KING 7839
JONES 7566 KING 7839
CLARK 7782 KING 7839
TURNER 7844
ADAMS 7876
JAMES 7900
SMITH 7369 FORD 7902
MILLER 7934
21 rows selected.
SQL>
SQL> ED
Wrote file afiedt.buf
1 SELECT E.ENAME,E.EMPNO,M.ENAME,M.EMPNO
2 FROM EMP E JOIN EMP M
3* WHERE E.MGR=M.EMPNO
SQL> ;
1 SELECT E.ENAME,E.EMPNO,M.ENAME,M.EMPNO
2 FROM EMP E JOIN EMP M
3* WHERE E.MGR=M.EMPNO
SQL> /
WHERE E.MGR=M.EMPNO
*
ERROR at line 3:
ORA-00905: missing keyword
SQL> ED
Wrote file afiedt.buf
1 SELECT E.ENAME,E.EMPNO,M.ENAME,M.EMPNO
2 FROM EMP E JOIN EMP M
3* ON E.MGR=M.EMPNO
SQL> /
ENAME EMPNO ENAME EMPNO
---------- ---------- ---------- ----------
SMITH 7369 FORD 7902
ALLEN 7499 BLAKE 7698
WARD 7521 BLAKE 7698
JONES 7566 KING 7839
MARTIN 7654 BLAKE 7698
BLAKE 7698 KING 7839
CLARK 7782 KING 7839
SCOTT 7788 JONES 7566
TURNER 7844 BLAKE 7698
ADAMS 7876 SCOTT 7788
JAMES 7900 BLAKE 7698
FORD 7902 JONES 7566
MILLER 7934 CLARK 7782
13 rows selected.
SQL> ED
Wrote file afiedt.buf
1 SELECT E.ENAME,E.EMPNO,M.ENAME,M.EMPNO
2 FROM EMP E NATURAL JOIN EMP M
3* WHERE E.MGR=M.EMPNO
SQL> /
WHERE E.MGR=M.EMPNO
*
ERROR at line 3:
ORA-25155: column used in NATURAL join cannot have qualifier
SQL> ED
Wrote file afiedt.buf
1 SELECT E.ENAME,E.EMPNO,M.ENAME,M.EMPNO
2 FROM EMP E JOIN EMP M
3* ON E.MGR=M.EMPNO
SQL> /
ENAME EMPNO ENAME EMPNO
---------- ---------- ---------- ----------
SMITH 7369 FORD 7902
ALLEN 7499 BLAKE 7698
WARD 7521 BLAKE 7698
JONES 7566 KING 7839
MARTIN 7654 BLAKE 7698
BLAKE 7698 KING 7839
CLARK 7782 KING 7839
SCOTT 7788 JONES 7566
TURNER 7844 BLAKE 7698
ADAMS 7876 SCOTT 7788
JAMES 7900 BLAKE 7698
FORD 7902 JONES 7566
MILLER 7934 CLARK 7782
13 rows selected.
SQL> ED
Wrote file afiedt.buf
1 SELECT E.ENAME,E.EMPNO,M.ENAME,M.EMPNO
2 FROM EMP E, EMP M
3* WHERE E.MGR=M.EMPNO
SQL> /
ENAME EMPNO ENAME EMPNO
---------- ---------- ---------- ----------
SMITH 7369 FORD 7902
ALLEN 7499 BLAKE 7698
WARD 7521 BLAKE 7698
JONES 7566 KING 7839
MARTIN 7654 BLAKE 7698
BLAKE 7698 KING 7839
CLARK 7782 KING 7839
SCOTT 7788 JONES 7566
TURNER 7844 BLAKE 7698
ADAMS 7876 SCOTT 7788
JAMES 7900 BLAKE 7698
FORD 7902 JONES 7566
MILLER 7934 CLARK 7782
13 rows selected.
SQL> SELECT ENAME,DENAME
2 FROM EMP, DEPT
3 WHERE EMP.DEPTNO=DEPT.DEPTNO(+);
SELECT ENAME,DENAME
*
ERROR at line 1:
ORA-00904: "DENAME": invalid identifier
SQL> ED
Wrote file afiedt.buf
1 SELECT ENAME,DNAME
2 FROM EMP, DEPT
3* WHERE EMP.DEPTNO=DEPT.DEPTNO(+)
SQL> /
ENAME DNAME
---------- --------------
SMITH RESEARCH
ALLEN SALES
WARD SALES
JONES RESEARCH
MARTIN SALES
BLAKE SALES
CLARK ACCOUNTING
SCOTT RESEARCH
KING ACCOUNTING
TURNER SALES
ADAMS RESEARCH
JAMES SALES
FORD RESEARCH
MILLER ACCOUNTING
14 rows selected.
SQL> ED
Wrote file afiedt.buf
1 SELECT ENAME,DNAME
2 FROM EMP, DEPT
3* WHERE EMP.DEPTNO(+)=DEPT.DEPTNO
SQL> /
ENAME DNAME
---------- --------------
CLARK ACCOUNTING
KING ACCOUNTING
MILLER ACCOUNTING
JONES RESEARCH
FORD RESEARCH
ADAMS RESEARCH
SMITH RESEARCH
SCOTT RESEARCH
WARD SALES
TURNER SALES
ALLEN SALES
JAMES SALES
BLAKE SALES
MARTIN SALES
OPERATIONS
15 rows selected.
SQL> ED
Wrote file afiedt.buf
1 SELECT ENAME,DNAME
2 FROM EMP FULL OUTER JOIN DEPT
3* ON EMP.DEPTNO=DEPT.DEPTNO
SQL> /
ENAME DNAME
---------- --------------
SMITH RESEARCH
ALLEN SALES
WARD SALES
JONES RESEARCH
MARTIN SALES
BLAKE SALES
CLARK ACCOUNTING
SCOTT RESEARCH
KING ACCOUNTING
TURNER SALES
ADAMS RESEARCH
JAMES SALES
FORD RESEARCH
MILLER ACCOUNTING
OPERATIONS
15 rows selected.
SQL> SPOOL OFF;