函数

来源:互联网 发布:松下fp x编程手册 编辑:程序博客网 时间:2024/06/05 04:03
 函数
    在select使用方式
    在where使用表达式
    在order by使用表达式
    +-*、||构成的表达式
    参与表达式运算的是:字段,常量(字面值)
    1.函数分类
       单行函数:
select name from dept where length(name)<10;
       字符串函数
       数学函数
select sin(30) from dual;
LOWER  
返回字符串,并将所有的字符小写
SQL> select lower('AaBbCcDd')AaBbCcDd from dual;
UPPER
返回字符串,并将所有的字符大写
SQL> select upper('AaBbCcDd') upper from dual;
忽略大小写的时候:
select name from dept where upper(name) like('KK%');
initcap把首字母转换成大写
select substr('hellocsdn',2,5) from dual;
3.CONCAT
连接两个字符串;
SQL> select concat('010-','888888188')||'转123'   from dual;
ROUND和TRUNC
按照指定的精度进行舍入
SQL> select round(55.5),round(-55.4),trunc(55.5),trunc(-55.5) from dual;
       日期函数 
       转换函数
       其他函数
       聚合函数:
select sum(salary) from dept;
     2.函数的参数可以使用:
常量,常量表达式
字段,字段表达式
另外函数的返回值:函数嵌套
to_char
select to_char(salary,'L000,000.0') from dept;L代表显示本地货币符号
select to_char(salary,'L999,999.9') from dept 9代表有0的时候显示,没有0的时候不显示
to_number
to_date
0 0
原创粉丝点击