Oralce 数据库字段、列数据类型转换
使用 cast 函数;
语法:cast( 列名/值 as 数据类型 )
实例:
-- 字符串转数字number
select cast('123.456' as number(10,2)) from dual
-- 字符串转s数字integer
select cast('123.456' as integer) from dual
-- 数字转字符串
select cast(123.456 as varchar2(100)) from dual
-- 字符串转时间戳
select cast('25-1月 -19 12.49.40.123456789 下午' as timestamp) from dual
-- 时间戳转字符串
select cast(to_timestamp(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss')||'.123456789','yyyy-mm-dd hh24:mi:ss.ff') as varchar2(100)) from dual
-- 字符串转日期
select cast('25-1月 -19' as date) from dual
-- 日期转字符串
select cast(sysdate as varchar2(100)) from dual