1、ASCIISTR(ch) 转换ch为ASCII字符串
SELECT ASCIISTR('AB?CDE张三') a1 FROM DUAL;
2、BIN_TO_NUM(ch) 转换位向量为一个数字[ch为逗号隔开的0或1]
SELECT BIN_TO_NUM(1,0,0,0) a1 FROM DUAL;--2的3次方[1000]
3、CAST(expr astype_name) 转换expr为type_name类型[前提是能够转换才行]
SELECT CAST(to_date('2013-01-0101:01:01','YYYY-MM-DDHH24:MI:SS') AStimestampWITHLOCALTIMEZONE) a1 FROM DUAL;
select CAST('12435'asnumber) a2 from dual;
4、CHARTOROWID(ch) 将字符串转换为ROWID类型
select CHARTOROWID('AAAFd1AAFAAAABSAA/') a1 from dual;
5、COMPOSE(ch)
6、CONVERT(ch,dest_ch_set,source_char_set)转换字符串为另一种字符串
SELECT CONVERT('? ¨o ¨a ? ? A B C DE ', 'US7ASCII', 'WE8ISO8859P1') a1 FROM DUAL;
7、DECOMPOSE(ch)
8、HEXTORAW(ch) 转换十六进制字符串为RAW类型
SELECT HEXTORAW('4041424344') a1 FROM DUAL;
SELECT UTL_RAW.CAST_TO_VARCHAR2(HEXTORAW('4041424344')) a1 FROM DUAL;
9、NUMTODSINTERVAL(n,interval_unit) 将数字与单位转换为内部时间格式, interval_unit格式有:DAY,HOUR,MINUTE,SECOND 【DS表示 DAY——>SECOND】
select sysdate+NUMTODSINTERVAL(10,'DAY')a1,sysdate+NUMTODSINTERVAL(10,'HOUR') a2,sysdate+NUMTODSINTERVAL(10,'MINUTE')a3,sysdate+NUMTODSINTERVAL(10,'SECOND') a4 from dual
10、NUMTOYMINTERVAL(n,interval_unit) 将数字与单位转换为内部时间格式, interval_unit格式有:YEAR ,MONTH【YM表示 YEAR——>MONTH】
select sysdate+NUMTOYMINTERVAL(10,'YEAR') a1,sysdate+NUMTOYMINTERVAL(10,'MONTH')a2 from dual
11、RAWTOHEX(raw) 转换RAW为十六进制字符串
12、RAWTONHEX(raw)= TO_NCHAR(RAWTOHEX(raw))
13、[url=]ROWIDTOCHAR(rowid)[/url] 将ROWID转换为字符串,长度18
select rowid,ROWIDTOCHAR(rowid) a1 from scott.emp;
14、ROWIDTONCHAR(rowid)=TO_NCHAR(ROWIDTOCHAR(rowid))
15、SCN_TO_TIMESTAMP(scn)将SCN转换为时间戳
SELECT SCN_TO_TIMESTAMP(ORA_ROWSCN) FROM tb_name WHERE pk_ID = 136512;
16、TIMESTAMP_TO_SCN(timestamp)将时间戳转换为SCN
select TIMESTAMP_TO_SCN(systimestamp) a1 from dual
17、TO_BINARY_DOUBLE(expr,fmt,nlspara)返回双精度类型数据
select TO_BINARY_DOUBLE(12) a1 from dual;
18、TO_BINARY_FLOAT(expr,fmt,nlspara)返回单精度类型数据
select TO_BINARY_FLOAT(12) a1 from dual;
19、TO_BLOB(raw_val) 转换LONG RAW和RAW数据为BLOB类型
[url=]SELECT[/url] TO_BLOB(raw_col) blobFROM tb_name;
20、[url=]TO_CHAR (character)[/url] 转换NCHAR,NVARCHAR2,CLOB,NCLOB为VARCHAR2类型
select to_char('Hello张三') a1 from dual;
21、TO_CHAR (datetime,fmt,nlspara)将时间相关;诶行转换为VARCHAR2类型
select TO_CHAR(systimestamp, 'YYYY-MM-DDHH24:MI:SSxFF') a1 FROM dual;
SELECT TO_CHAR(INTERVAL'123-2'YEAR(3) TOMONTH) a1 FROM DUAL;
22、TO_CHAR(number,fmt,nlspara) 将数字相关类型NUMBER, BINARY_FLOAT, or BINARY_
DOUBLE转换为VARCHAR2类型
SELECT TO_CHAR(-10000,'L99G999D99MI') a1 FROM DUAL;
SELECT TO_CHAR(-10000,'L99G999D99MI','NLS_NUMERIC_CHARACTERS= '',.''NLS_CURRENCY = ''AusDollars'' ') a1 FROM DUAL;
23、[url=]TO_CLOB(ch)[/url]将字符串转换为CLOB类型
UPDATE tb_name SET clob_col = TO_CLOB(data);
24、TO_DATE(ch,fmt,nlspara)将字符串转换为Date类型
SELECT TO_DATE('January 15, 1989,11:00 A.M.','Month dd, YYYY,HH:MI A.M.','NLS_DATE_LANGUAGE =American') a1 FROM DUAL;
SELECT TO_DATE('2012-12-0110:01:02','YYYY-MM-DDHH24:MI:SS') a1 FROM DUAL;
25、TO_DSINTERVAL(fmt) 转换一个格式字符串为一个内部的 DAY——>SECOND
select sysdate+TO_DSINTERVAL('10 00:00:00') a1 from dual;--加10天
select sysdate+TO_DSINTERVAL(to_char(sysdate,'DD hh24:mi:ss')) a1 from dual;--加上当前时间的时分秒
26、TO_YMINTERVAL(fmt) 转换一个格式字符串为一个内部的 YEAR——>MONTH
select sysdate+TO_YMINTERVAL('01-03') a1 from dual;--加15个月
select sysdate+TO_YMINTERVAL(to_char(sysdate,'yyyy-MM')) a1 from dual;
27、TO_LOB(long) 转换long和long raw类型为LOB类型
SELECT TO_LOB(long_col) lob FROM tb_name;
28、TO_MULTI_BYTE(ch) 将字符串转换为双字节表示
select [url=]TO_MULTI_BYTE[/url]('Hello张三') a1 from dual;
29、TO_NCHAR (character)转换NCHAR,NVARCHAR2,CLOB,NCLOB为NVARCHAR2类型
select to_nchar('Hello张三') a1 from dual;
30、TO_NCHAR (datetime,fmt,nlspara)将时间相关;诶行转换为NVARCHAR2类型
select TO_NCHAR(systimestamp, 'YYYY-MM-DDHH24:MI:SSxFF') a1 FROM dual;
SELECT TO_NCHAR(INTERVAL'123-2'YEAR(3) TOMONTH) a1 FROM DUAL;
31、TO_NCHAR (number,fmt,nlspara)将数字相关类型NUMBER, BINARY_FLOAT, or BINARY_
DOUBLE转换为NVARCHAR2类型
SELECT TO_NCHAR(-10000,'L99G999D99MI') a1 FROM DUAL;
SELECT TO_NCHAR(-10000,'L99G999D99MI','NLS_NUMERIC_CHARACTERS= '',.''NLS_CURRENCY = ''AusDollars'' ') a1 FROM DUAL;
32、TO_NCLOB(ch) 将字符串转换为NCLOB类型
UPDATE tb_name SET nclob_col = TO_NCLOB(data);
33、TO_NUMBER(expr,fmt,nlspara)格式化数字输出
SELECT TO_NUMBER('-AusDollars100','L9G999D99','NLS_NUMERIC_CHARACTERS = '',.''NLS_CURRENCY = ''AusDollars''') a1 FROM DUAL;
34、TO_SINGLE_BYTE(ch) 转换为单字节字符 ch类型可以是 CHAR,VARCHAR2, NCHAR, or NVARCHAR2,不能是CLOB
selectTO_SINGLE_BYTE('Hello张三') a1 from dual;
35、TO_TIMESTAMP(ch,fmt,nlspara)转换为时间戳
SELECT TO_TIMESTAMP('2013-09-3014:10:10.12320', 'YYYY-MM-ddHH24:MI:SS.FF') a1FROM DUAL;
36、TO_TIMESTAMP_TZ(ch,fmt,nlspara)转换为带时区的时间戳
SELECT TO_TIMESTAMP_TZ('2013-09-3014:10:10.12320', 'YYYY-MM-dd HH24:MI:SS.FF') a1 FROM DUAL;
37、TRANSLATE (ch USINGCHAR_CS|NCHAR_CS) 将字符串转换为规定的字符集
select TRANSLATE('Hello张三' USING CHAR_CS) a1,TRANSLATE('Hello张三' USING NCHAR_CS) a2 from dual
38、UNISTR(string) 将字符串转换为AL16UTF16或 UTF8字符
select UNISTR('Hello张三') a1 from dual;
万望 发表于 2016-7-19 17:29
又是一波硬货,吃的太饱,吃不下啦
欢迎光临 度量快速开发平台-专业、快速的软件定制快开平台 (http://plat.delit.cn/) | Powered by Discuz! X3.2 |