IhАr [email protected]@GTRGFPHVUG6SDID`6aH6F 01

[email protected]@GÃTRGÃFPHVUG6SDIDÃ`6aH6FÃÃ
Ih€rÃ
Dört
NULL
øúyr€
Alias
Bˆvqryvr†Ã
• Sorgulama yapmap için SELECT statemen‡ÕÃxˆyyhÕyՅ
ç
ç
ç
ç SELECT clauseuna sadece görülmesi istenen columnlar ya
SELECT [DISTINCT] {* | column [alias], ...} FROM table
SELECT * FROM dept
SELECT deptno, dname, loc FROM dept
SELECT loc, dname, deptno FROM dept
SELECT deptno, loc FROM dept
SELECT ename, sal, sal + 300 FROM emp
SELECT ename, sal, 12 * sal + 100 FROM emp
SELECT ename, sal, 12 * (sal + 100) FROM emp
[email protected]@8UÃpyhˆ†rˆqhxvÃÃvúh…r‡vǁ€Ãp‚yˆ€yh…Ãhyh€ÕhÃtryv…
[email protected]@8UÃpyhˆ†rˆhÇhiyrqhxvÃp‚yˆ€yh…ՁÃurƒ†vÒh“Õyhivyv…
[email protected]@8UÃpyhˆ†rˆhÇhiyrqhxvÃp‚yˆ€yh…ՁÃurƒ†vÃv†‡rrÃ†Õ…hqhÒh“Õyhivyv…
“Õyhivyv…
• ASPHÃpyhˆ†rˆÃqÕúՁqhÃi‡Ãpyhˆ†ryh…qhÃh…v‡€r‡vxÃvúyr€yr…Ã-xˆyyhÕyhivyv…
• T‚ˆoyh…ÕÃt|†‡r…€rxÃvovÃ†hqrprÃrx…hhÒrvÃp‚yˆ€yh…ÃhoÕyՅÃUhiyrhÃh†yhÃhoÕy€h“
• gpryvxÆՅh†ÕÃ-ÂyˆƒÃvúyr€yr…Ãh’ÕÃ|pryv÷rÆhuvƒ†rƂyqhÃ†h÷hҁ……
• 7v…Ãp‚yˆ€ÃIPUÃIVGGÒhqhÃQ…v€h…’ÃFr’Âyh…hxÒh…h‡Õy€hqՒ†hÃIVGGÃqr÷r…Ã
içerebilir
• IVGGÃh‡h€h€ÕúÃivyv€r’rÃiv…Ãqr÷r…qv…ÃIVGG13ÃIVGG13¶¶ÃIVGG13¶Ãµ
• IVGGÃqr÷r…yvÃiv…Ãh…v‡€r‡vxÃvúyr€vÃ†‚ˆpˆÃIVGGÂyˆ…
• 7v…Ãp‚yˆ€Ãv†€vvÃrx…hqhÃsh…xyÕÃv†v€yrÃt|†‡r…€rÂyh’ՁhÃhyvh†Ã‡hÕ€yh€hÃqrv…
• 8‚yˆ€yh…ÕÃihúxhÃp‚yˆ€yh…yhh…v‡€r‡vxÃvúyr€yr…yrÉr’hÆhiv‡Ãqr÷r…yr…yrÃiv…yrú‡v…v…
• [email protected]@8UÃpyhˆ†rˆqhÃp‚yˆ€yh…ՁÃiv…yrúv€vvÃx‚yh’ÃhyhúÕy€h†ÕÃvovÃxˆyyhÕyhÃ
SELECT ename, sal, 12 * sal + comm FROM emp
SELECT ename Name, job, sal “Annual Salary $” FROM emp
Column
7v…yrú
SELECT ename||’ is a ‘||job||’ and will earn ‘|| sal * 12 || ’ $ in year ’||2000 Employee FROM emp
xh…hx‡r…yr…Ãqv“v†vrÃGv‡r…hyÃxh…hx‡r…yr…Ãqrv…ÃUh…vuÃxh…hx‡r…yr…õ¶ÃvovrÃhyՁ€hyÕÃ
tirmek
†h’Õyh…Ãv†rÂyqˆ÷ˆÃtvivÒh“Õy€hyÕqՅ
Unique
p‚yˆ€yh…ՁÃivyrúv€vvÃˆv„ˆrÃqr÷r…yr…vvÃt|†‡r…v…
96U6`DÃTDIDSG6I9DSH6FÃW@ÃTDS6G6H6FÃÃ
Ih€rÃ
Where
• SELECT clau†rˆqhxvÃ9DTUDI8UÃxr’Ђ…qÃxrqv†vqrÃ†‚…hÒh“ÕyhÃ
SELECT DISTINCT deptno FROM emp
SELECT DISTINCT deptno, job FROM emp
Bˆvqryvr†Ã
• WHERE claˆ†rˆÃq|q…yrprxłÃ†h’Õ†ÕÆՁՅyhqՅÕyՅ
SELECT [DISTINCT] {* | column [alias], ...} FROM table [WHERE condition(s)]
ç
ç Hiredate’i 01-JANç
ç
anlar
ç
ç Mgr’si 7902, 7566 yada 7788 olanlar
ç Ename’i FORD yada ALLEN olanlar
ç
ç Hiredate’i 01-JAN-81 ile 31-DECç Ename’inin ikinci harfi A olanlar
ç Comm’u NULL olanlar
ç Gerçek % vaya _ karakterlerini kullanmak içi
ç Sal’i 1100’den büyük ve job
ç
ç
ç
ç
ç Ename’inde A harfi olmayanlar
ç Comm’u NULL olmayanlar
@h€r¶vÃ[email protected]Âyhyh…õ¶ÃvovrÒh“ÕyՅÃÃph†rÆr†r‡v‰rqv…
Logical
Operators
SELECT * FROM emp WHERE ename = ‘JAMES’
SELECT * FROM emp WHERE hiredate = ’01-JAN-95’
SELECT * FROM emp WHERE deptno = 10
SELECT * FROM emp WHERE sal <= comm
SELECT * FROM emp WHERE sal BETWEEN 1000 AND 1500
SELECT * FROM emp WHERE mgr IN (7902, 7566, 7788)
SELECT * FROM emp WHERE ename IN (‘FORD’, ‘ALLEN’)
SELECT * FROM emp WHERE ename LIKE ‘S%’
SELECT * FROM emp WHERE hiredate LIKE ‘%81’
SELECT * FROM emp WHERE ename LIKE ‘_A%’
SELECT * FROM emp WHERE comm IS NULL
SELECT * FROM emp WHERE ename LIKE ‘\%A\_\%B’ ESCAPE ‘\’
ODD
ÕU6
TRUE
T
F
U
FALSE
F
F
F
UNKNOWN
U
F
U
ÃvryÃ
$Ãh…h†ÕqhÂy
@h€r¶vÃTÃuh…svÃvyrÃihúyh’hyh…
'
PSÃ
TRUE
FALSE
UNKNOWN
Ãh…h†ÕqhÂyhyh…
Ã@T86Q@õ¶ÃxˆyyhÕyՅ
¶ÕÃ[email protected]Âyhyh…
Thy¶vÃ
¶qrÃi’xÉr’hÃw‚i¶ÕÃ[email protected]Âyhyh…
E‚i¶ÕÃ[email protected]Ã[email protected]Ã6I6G`TUÂy€h’hyh…
E‚i¶ÕÃ[email protected]Ã[email protected]Ã6I6G`TUÂy€h’hyh…
Thy¶vÃ
ç
ç
ç
ç
SELECT * FROM emp ORDER BY hiredate
SELECT * FROM emp ORDER BY hiredate DESC
SELECT ename, sal * 12 annsal FROM emp ORDER BY annsal
SELECT ename, sal, job FROM emp ORDER BY deptno, sal DESC, job
6I9Ã
Âyhyh…ÃTh’Õyh…Âyqˆ÷ˆÃtvivÒh“ÕyՅ
Thy¶vÃp‚€€¶qhÃxoxÉr’hÃrúv‡Ã‚yhyh…
Thy¶vÃ
SELECT * FROM emp WHERE sal >= 1100 AND job = ‘CLERK’
SELECT * FROM emp WHERE sal >= 1100 OR job = ‘CLERK’
SELECT * FROM emp WHERE job NOT IN (‘CLERK’, ‘MANAGER’, ‘ANALYST’)
SELECT * FROM emp WHERE NOT job IN (‘CLERK’, ‘MANAGER’, ‘ANALYST’)
SELECT * FROM emp WHERE sal NOT BETWEEN 1000 AND 1500
SELECT * FROM emp WHERE ename NOT LIKE ‘%A%’
SELECT * FROM emp WHERE comm IS NOT NULL
SELECT * FROM emp WHERE job = ‘SALESMAN’ OR job = ‘PRESIDENT’ AND sal > 1500
SELECT * FROM emp WHERE (job = ‘SALESMAN’ OR job = ‘PRESIDENT’) AND sal > 1500
TRUE
FALSE
UNKNOWN
-MON-YY’
($Âyhyh…õ¶ÃvovrÒh“ÕyՅÃÃ9rshˆy‡Ãs‚…€h‡Ãµ99
9rƒ‡‚¶†ˆÃ
TRUE
T
T
T
FALSE
T
F
U
ÃvyrÃ
$Ãh…h†ÕqhÂy€h’hyh…
1
2
3
4
5
gpryvxÃTՅh†Õ
Operator
(...)
=,<>,>=,...
NOT
AND
OR
Hireqh‡r¶‡rxvÃrÃr†xvÇh…vu‡rÃrÃ†‚Ã‡h…vurÃt|…rÆÕyh…hy€hÒhƒh…
Cv…rqh‡r¶‡rxvÃrÃ†‚Ã‡h…vu‡rÃrÃr†xvÇh…vurÃt|…rÆÕyh…hy€hÒhƒh…
6yvh†yh…hÃt|…rÃqrÆՅhyh€hÒhƒh…
[email protected]Ã7`Ãpyhˆ†rˆqhxvÃiv…Ãp‚yˆ€ˆÃ[email protected]@8UÃpyhˆ†rˆqhÂy€h†ÕÃúh…‡Ãqr÷vy
UNKNOWN
T
U
U
NOT
TRUE
FALSE
UNKNOWN
F
T
U