oracle練習5-操作字串的函式
阿新 • • 發佈:2019-01-29
字串的大小寫操作
小寫lower,大寫upper,首字母大寫initcap
19:16:38 SQL> select lower(ename),upper(ename),initcap(ename) from emp;
LOWER(ENAM UPPER(ENAM INITCAP(EN
---------- ---------- ----------
smith SMITH Smith
allen ALLEN Allen
ward WARD Ward
jones JONES Jones
martin MARTIN Martin
blake BLAKE Blake
clark CLARK Clark
king KING King
turner TURNER Turner
james JAMES James
ford FORD Ford
LOWER(ENAM UPPER(ENAM INITCAP(EN
---------- ---------- ----------
miller MILLER Miller
已選擇12行。
已用時間: 00: 00: 00.04
19:17:16 SQL>
其它字串操作函式
19:17:16 SQL> select ename,job,concat(ename,job) from emp;
ENAME JOB CONCAT(ENAME,JOB)
---------- --------- -------------------
SMITH CLERK SMITHCLERK
ALLEN SALESMAN ALLENSALESMAN
WARD SALESMAN WARDSALESMAN
JONES MANAGER JONESMANAGER
MARTIN SALESMAN MARTINSALESMAN
BLAKE MANAGER BLAKEMANAGER
CLARK MANAGER CLARKMANAGER
KING PRESIDENT KINGPRESIDENT
TURNER SALESMAN TURNERSALESMAN
JAMES CLERK JAMESCLERK
FORD ANALYST FORDANALYST
ENAME JOB CONCAT(ENAME,JOB)
---------- --------- -------------------
MILLER CLERK MILLERCLERK
已選擇12行。
已用時間: 00: 00: 00.03
將兩個字元連線到一起
下面三句話是求字串的長度,字串要單引。
select length('張三') from dual;--按照字
select lengthb('張三') from dual;--按位元組
select lengthc('張三') from dual;--unicode 的長度
19:58:19 SQL> select length('張三') from dual;
LENGTH('張三')
--------------
2
已用時間: 00: 00: 00.00
19:58:55 SQL> select lengthb('張三') from dual;
LENGTHB('張三')
---------------
4
已用時間: 00: 00: 00.01
19:59:31 SQL> select lengthc('張三') from dual;
LENGTHC('張三')
---------------
2
已用時間: 00: 00: 00.01
20:00:03 SQL>
小寫lower,大寫upper,首字母大寫initcap
19:16:38 SQL> select lower(ename),upper(ename),initcap(ename) from emp;
LOWER(ENAM UPPER(ENAM INITCAP(EN
---------- ---------- ----------
smith SMITH Smith
allen ALLEN Allen
ward WARD Ward
jones JONES Jones
martin MARTIN Martin
blake BLAKE Blake
clark CLARK Clark
king KING King
turner TURNER Turner
james JAMES James
ford FORD Ford
LOWER(ENAM UPPER(ENAM INITCAP(EN
---------- ---------- ----------
miller MILLER Miller
已選擇12行。
已用時間: 00: 00: 00.04
19:17:16 SQL>
其它字串操作函式
19:17:16 SQL> select ename,job,concat(ename,job) from emp;
ENAME JOB CONCAT(ENAME,JOB)
---------- --------- -------------------
SMITH CLERK SMITHCLERK
ALLEN SALESMAN ALLENSALESMAN
WARD SALESMAN WARDSALESMAN
JONES MANAGER JONESMANAGER
MARTIN SALESMAN MARTINSALESMAN
BLAKE MANAGER BLAKEMANAGER
CLARK MANAGER CLARKMANAGER
KING PRESIDENT KINGPRESIDENT
TURNER SALESMAN TURNERSALESMAN
JAMES CLERK JAMESCLERK
FORD ANALYST FORDANALYST
ENAME JOB CONCAT(ENAME,JOB)
---------- --------- -------------------
MILLER CLERK MILLERCLERK
已選擇12行。
已用時間: 00: 00: 00.03
將兩個字元連線到一起
下面三句話是求字串的長度,字串要單引。
select length('張三') from dual;--按照字
select lengthb('張三') from dual;--按位元組
select lengthc('張三') from dual;--unicode 的長度
19:58:19 SQL> select length('張三') from dual;
LENGTH('張三')
--------------
2
已用時間: 00: 00: 00.00
19:58:55 SQL> select lengthb('張三') from dual;
LENGTHB('張三')
---------------
4
已用時間: 00: 00: 00.01
19:59:31 SQL> select lengthc('張三') from dual;
LENGTHC('張三')
---------------
2
已用時間: 00: 00: 00.01
20:00:03 SQL>