select ascii(A) A,ascii(a) a,ascii(0) zero,ascii( ) space from dual; A A ZERO SPACE --------- --------- --------- --------- 65 97 48 32 " />
1. ASCII
返回與指定的字符對應(yīng)的十進(jìn)制數(shù);
SQL> select ascii(A) A,ascii(a) a,ascii(0) zero,ascii( ) space from dual;
A A ZERO SPACE
--------- --------- --------- ---------
65 97 48 32
2. CHR給出整數(shù),返回對應(yīng)的字符;
SQL> select chr(54740) zhao,chr(65) chr65 from dual;
ZH C
-- -
趙A
3. CONCAT
連接兩個字符串;
SQL> select concat(010-,88888888)||轉(zhuǎn)23 高乾競電話 from dual;
高乾競電話
----------------
010-88888888轉(zhuǎn)23
4. INITCAP
返回字符串并將字符串的第一個字母變?yōu)榇髮?
SQL> select initcap(smith) upp from dual;
UPP
-----
Smith
5.INSTR(C1,C2,I,J)在一個字符串中搜索指定的字符,返回發(fā)現(xiàn)指定的字符的位置;
C1被搜索的字符串
C2希望搜索的字符串
I 搜索的開始位置,默認(rèn)為1 J 出現(xiàn)的位置,默認(rèn)為1 SQL> select instr(oracle traning,ra,1,2) instring from dual;
INSTRING
---------
9
6.LENGTH
返回字符串的長度;
SQL> select name,length(name),addr,length(addr),sal,length(to_char(sal)) from gao.nchar_tst;
NAME LENGTH(NAME) ADDR LENGTH(ADDR) SAL LENGTH(TO_CHAR(SAL))
------ ------------ ---------------- ------------ --------- --------------------
高乾競 3 北京市海錠區(qū) 6 9999.99 7
7.LOWER返回字符串,并將所有的字符小寫
SQL> select lower(AaBbCcDd)AaBbCcDd from dual;
AABBCCDD
--------
aabbccdd
8.UPPER返回字符串,并將所有的字符大寫
SQL> select upper(AaBbCcDd) upper from dual;
UPPER
--------
AABBCCDD
9.RPAD和LPAD(粘貼字符)
RPAD在列的右邊粘貼字符
LPAD在列的左邊粘貼字符
SQL> select lpad(rpad(gao,10,*),17,*)from dual;
LPAD(RPAD(GAO,1
-----------------
*******gao*******
不夠字符則用*來填滿
10.LTRIM和RTRIM
LTRIM刪除左邊出現(xiàn)的字符串
RTRIM刪除右邊出現(xiàn)的字符串
SQL> select ltrim(rtrim( gao qian jing , ), ) from dual;
LTRIM(RTRIM(
-------------
gao qian jing
11.SUBSTR(string,start,count)取子字符串,從start開始,取count個SQL> select substr(13088888888,3,8) from dual;
SUBSTR(
--------
08888888
12.REPLACE(string,s1,s2)
string希望被替換的字符或變量
s1被替換的字符串
s2要替換的字符串
SQL> select replace(he love you,he,i) from dual;
REPLACE(H
----------
i love you
13.SOUNDEX
返回一個與給定的字符串讀音相同的字符串
SQL> create table table1(xm varchar(8));
SQL> insert into table1 values(weather);
SQL> insert into table1 values(wether);
SQL> insert into table1 values(gao);
SQL> select xm from table1 where soundex(xm)=soundex(weather);
XM
--------
weather
wether
14.TRIM(s from string)
LEADING剪掉前面的字符
TRAILING剪掉后面的字符
如果不指定,默認(rèn)為空格符
15.ABS
返回指定值的絕對值
SQL> select abs(100),abs(-100) from dual;
ABS(100) ABS(-100)
--------- ---------
100 100
16.ACOS
給出反余弦的值
SQL> select acos(-1) from dual;
ACOS(-1)
---------
3.1415927
17.ASIN
給出反正弦的值
SQL> select asin(0.5) from dual;
ASIN(0.5)
---------
.52359878
18.ATAN
返回一個數(shù)字的反正切值
SQL> select atan(1) from dual;
ATAN(1)
---------
.78539816
19.CEIL
返回大于或等于給出數(shù)字的最小整數(shù)
SQL> select ceil(3.1415927) from dual;
CEIL(3.1415927)
---------------
4
20.COS
返回一個給定數(shù)字的余弦
SQL> select cos(-3.1415927) from dual;
COS(-3.1415927)
---------------
-1
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com