設定:
set linesize xxx 查詢資料每行顯示長度 (bit)
set heading off 不顯示每行的列名顯示
set echo off 不顯示執行語法後執行的SQL語句
set pages0 不進行分頁顯示
set feed off 不顯示SQL運行的結果
set feedback off 不顯示當前SQL語句查詢或修改的行數
函數運用:
select 'ABCDE' from dual;
顯示: ABCDE
INITCAP(string) 將字串中每個單字的第一個字母變成大寫,其他變成小寫(如有數字不變)。
select INITCAP('ABCDE') from dual;
顯示: Abcde
INSTR(string1,string2) 檢查string1字串,找到string2 回傳string2在string1字串的位置。
select INSTR('ABCDE','D') from dual;
顯示: 4
select INSTR('ABCDE','d') from dual;
顯示: 0
LENGTH(string)回傳字串字元數量
select LENGTH('ABCDE') from dual;
顯示: 5
select LENGTH('AB C DE') from dual;
顯示:7
LOWER(string)將字串中所有字元轉成小寫。
UPPER(string)將字串中所有字元轉成大寫。
select LOWER('aBcdE') from dual;
顯示: abcde
select UPPER('aBcdE') from dual;
顯示: ABCDE
RPAD(string1,string2,string3) string1字串向右填補至(string2)位數,補入string3字元(string3不給則補入空格)。
LPAD(string1,string2,string3) string1字串向右填補至(string2)位數,補入string3字元(string3不給則補入空格)。
select RPAD('aBcdE',10,'F') from dual;
顯示:aBcdEFFFFF
select LPAD('aBcdE',10,'F') from dual;
顯示:FFFFFaBcdE
select RPAD('aBcdE',10) from dual;
顯示:aBcdE (後面有5個空格)
TRIM(string) 將string字串的左右,移除空白字元
select trim(' aB c d E ') from dual;
顯示:aB c d E
RTRIM(string1,string2) 將string1字串從右邊開始,移除string2字元(不是string2字元就停止,不給string2則預設為空白)。
LTRIM(string1,string2) 將string1字串從左邊開始,移除string2字元(不是string2字元就停止,不給string2則預設為空白)。
select rtrim('EEeaBc dEFEeEEE','E') from dual;
顯示:EEeaBc dEFEe
select ltrim('EEeaBc dEFEeEEE','E') from dual;
顯示:eaBc dEFEeEEE
REPLACE(string1,string2,string3) 字串取代,將string1字串中,含有string2字元,取代成string3字元(string3不給則清除string2字元)
select replace('EEeaBc dEFEeEEE','E','x') from dual;
顯示:xxeaBc dxFxexxx
select replace('EEeaBc dEFEeEEE','E') from dual;
顯示:eaBc dFe
SUBSTR(string,x,y)回傳字串string的一部分,x指定開始位數,y指令回傳數量。
select SUBSTR('EEeaBc dEFEeEEE',5,6) from dual;
顯示:Bc dEF
TRANSLATE(string1,string2,string3) 修改字串中字元組轉換成另一個字元組
後續待補~
留言列表