您的位置:首页 > 数据库 > Oracle

Oracle基础学习----函数

2009-11-02 10:31 507 查看
Oracle中的date日期型:

select sysdate from 任意表名 显示当前系统时间

转换函数

一:

to_date()函数

to_date('05/30/08 13:30:30','mm/dd/yy hh24:mi:ss');



to_number()



to_char()

1. 日期-》字符

to_char(Date);

to_char(Date,’yyyy-mm-dd’);

2. 数字-》字符

to_char(number,’format’);

to_char(12345,678901,’$99,999.0000’);结果$12.345.6789

数字模式符:

格式符 说明

9 代表一位数字

0 代表一位数字,强制显示0

$ 放置一个美元符

L 放置一个本地货币符

. 小数点

, 千位指示符

通用函数

一:NVL()函数

NVL(exp1,exp2)//如果exp1的值为null,则返回exp2的值

二:NVL2()函数

NVL2(exp1,exp2,exp3)

如果exp1的值不为null,则返回exp2的值,否则返回exp3的值

三:NULLIF()函数

nullif(exp1,exp2)

如果exp1与exp2的值相等则返回null,否则返回exp1的值

四:COALESCE()函数

coalesce(exp1,exp2,…)

依次考察各参数,遇到非null值即停止并返回该值。如果没有遇到返回null

五:CASE表达式

case exp

when config_exp1 then return_exp1

when config_exp2 then return_exp2

when config_exp3 then return_exp3

else else_exp

end

六:DECODE()函数

类似CASE();

Decode(exp,

config_exp1,return_exp1,

config_exp2,return_exp2,

config_exp3,return_exp3,

else_exp)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: