Oracle_071_lesson_p4

函数

单行函数 single-row functions
多行函数 mutilple-row functions

单行函数:
字符函数
lower 小写 如where lower(last_name)='HH';
upper 大写 如where upper(last_name)='hh'; 生产维护中用的比较多
initcap 首字母大写 如where initcap(last_name)='Test';
concat 连接 类似|| 如concat(last_name,first_name) ,只能2个参数
substr(column,0,4) 从左到右,默认开始位为1, 此为输出4个字符
substr(column,-5,4) 倒数第5位起,取4位输出
substr(column,4) 从第4位开始取,直到结束
instr(column,'t') 找t在第几位
length('abc') 此计算输出字符长度为3
函数可嵌套,计算是从里到外的顺序

数字函数
round(45.926,2) 四舍五入,此输出45.93 ,那么如果round(-45.926) ,输出是多少呢?
trunc(45.926,2) 只保留小数点后2位,此输出为45.92
ceil(2.83) 向上取整,此输出为3,那么如果ceil(-2.83),输出是多少呢?
floor(2.83) 向下取整,此输出为2,那么如果ceil(-2.83),输出是多少呢?
mod(1600,300) 求模,即余数

日期函数
理解此图:
Oracle_071_lesson_p4
select sysdate from dual;

修改时间格式:alter system set nls_date_format='yyyy-mm-dd hh24:mi:ss' scope=spfile;

Oracle_071_lesson_p4

猜你喜欢

转载自blog.51cto.com/3938853/2152492
今日推荐