UPPER | 大文字に変換して表示 |
---|---|
LOWER | 小文字に変換して表示 |
INITCAP | 先頭の1文字を大文字に変換して表示 |
LENGTH | 文字数を表示 |
SUBSTR | 特定の文字数だけ抽出して表示 |
INSTR | 指定した文字が何行目なのかを表示 |
LPAD | 左側に文字を埋め込み表示 |
RPAD | 右側に文字を埋め込み表示 |
TRIM | 指定した文字を取り除いて表示 |
REPLACE | 指定した文字を置き換えて表示 |
SQL> SELECT upper(first_name) FROM employees;
UPPER(FIRST_NAME)
------------------------------
SUZUKI
SATO
YAMAMOTO
WATANABE
WATANABE
KATAOKA
HARADA
KODA
SAITO
AKAGI
…
20 rows selected.
SQL> SELECT lower(first_name) FROM employees;
LOWER(FIRST_NAME)
------------------------------
suzuki
sato
yamamoto
watanabe
watanabe
kataoka
harada
koda
saito
akagi
…
20 rows selected.
SQL> SELECT initcap(first_name) FROM employees;
INITCAP(FIRST_NAME)
------------------------------
Suzuki
Sato
Yamamoto
Watanabe
Watanabe
Kataoka
Harada
Koda
Saito
Akagi
…
20 rows selected.
SQL> SELECT first_name FROM employees 2> WHERE upper(first_name) = 'HARADA'; FIRST_NAME ------------------------------ Harada
SQL> SELECT concat(first_name,last_name) FROM employees;
CONCAT(FIRST_NAME,LAST_NAME)
------------------------------------------------------------
SuzukiHiroshi
SatoTakashi
YamamotoKeiko
Watanabeyoko
WatanabeSawa
KataokaTomonori
HaradaOsamu
KodaRiku
SaitoRyota
AkagiYumi
…
20 rows selected.
SQL> SELECT first_name || last_name FROM employees;
FIRST_NAME||LAST_NAME
------------------------------------------------------------
SuzukiHiroshi
SatoTakashi
YamamotoKeiko
Watanabeyoko
WatanabeSawa
KataokaTomonori
HaradaOsamu
KodaRiku
SaitoRyota
AkagiYumi
…
20 rows selected.
SQL> SELECT first_name,length(first_name) FROM employees;
FIRST_NAME LENGTH(FIRST_NAME)
------------------------------ ------------------
Suzuki 6
Sato 4
Yamamoto 8
Watanabe 8
Watanabe 8
Kataoka 7
Harada 6
Koda 4
Saito 5
Akagi 5
…
20 rows selected.
SQL> SELECT first_name,length(first_name) FROM employees 2> WHERE length(first_name) >= 5;
SUBSTR(first_name,3,2) | first_nameの3文字目から 2文字分を表示 |
---|---|
SUBSTR(first_name,3) | first_nameの3文字目以降 を表示 |
SUBSTR(first_name,0,3) | first_nameの最初から 3文字分を表示 |
SQL> SELECT first_name,instr(first_name,'m') FROM employees;
FIRST_NAME INSTR(FIRST_NAME,'M')
------------------------------ ---------------------
Suzuki 0
Sato 0
Yamamoto 3
…
Totsuka 0
Kato 0
Sinagawa 0
Kuroda 0
Nakamura 5
Kamata 3
Ito 0
20 rows selected.
SQL> SELECT first_name,lpad(first_name,10,'*') FROM employees;
FIRST_NAME LPAD(FIRST_NAME,10,'
------------------------------ --------------------
Suzuki ****Suzuki
Sato ******Sato
Yamamoto **Yamamoto
Watanabe **Watanabe
Watanabe **Watanabe
Kataoka ***Kataoka
Harada ****Harada
Koda ******Koda
Saito *****Saito
Akagi *****Akagi
…
20 rows selected.
SQL> SELECT first_name,trim('S' from first_name) FROM employees;
FIRST_NAME TRIM('S'FROMFIRST_NAME)
------------------------------ ------------------------------
Suzuki uzuki
Sato ato
Yamamoto Yamamoto
Watanabe Watanabe
Watanabe Watanabe
…
20 rows selected.
SQL> SELECT first_name,replace(first_name,'a','o') FROM employees;
FIRST_NAME REPLACE(FIRST_NAME,'A','O')
------------------------------ ------------------------------
Suzuki Suzuki
Sato Soto
Yamamoto Yomomoto
Watanabe Wotonobe
Watanabe Wotonobe
Kataoka Kotooko
…
20 rows selected.