zoukankan      html  css  js  c++  java
  • sql语句 字符函数,数字函数

     1 -- 字符函数
     2 
     3 -- ASCII(X) 返回字符x 的 ASCII码
     4 select ASCII('a') FROM DUAL;    -- 返回97
     5 
     6 -- CONCAT(X,Y) 连接字符串x和y
     7 select  concat('123',' 456') from dual;  -- 返回 123 456
     8 
     9 -- INSTR(X,str [,start][,n) :在x中查找str,可以指定从start开始,也可以指定从第n次开始
    10 select instr('hahdf','f') from dual;  -- 返回str的位置
    11 
    12 -- length(x) 返回x的长度
    13 select length('d545') from dual;  --返回4
    14 
    15 -- lower(x)   将x转变为小写
    16 select lower('ABCD') from dual; -- 返回abcd
    17 
    18 -- upper(x)  将x转变为大写
    19 select upper('abcde') from dual;  -- 返回ABCDE
    20 
    21 -- ltrim(x,[str]) 把x的左边截去str 字符串,缺省截去空格
    22 SELECT ltrim('===HELLO===', '=') FROM DUAL  -- 返回  HELLO===
    23 
    24 
    25 -- rtrim(x,[str]) 把x的右边截去str 字符串,缺省截去空格
    26 SELECT rtrim('===HELLO===', '=') FROM DUAL  -- 返回  ===HELLO
    27 
    28 -- trim([str from] x) 把x的两边截去str 字符串,缺省截去空格
    29 SELECT TRIM('=' FROM '===HELLO===') FROM DUAL; -- 返回  HELLO
    30 
    31 -- replace(x,old,new) 在x中查找old, 并替换为new
    32 select replace('avaddfs','d','e') from dual; -- 返回结果avaeefs
    33 
    34 -- substr(x,start,[,length]) 返回x的字符串,从start处开始,
    35 --截取length个字符,缺省length,默认到结尾
    36 select substr('abcdefg',2,4) from dual;--返回:bcde
    37 
    38 
    39 -- 数学函数
    40 -- abs(x) x绝对值
    41 select abs(-5) from dual; -- 返回  5
    42 
    43 -- acos(x) x的反余弦
    44 select acos(1) from dual; -- 返回0
    45 
    46 -- cos(x) 余弦
    47 select cos(1) from dual; -- 返回0.54030230586814
    48 
    49 -- ceil(x) 大于或等于x的最小值
    50 select ceil(5.2) from dual; -- 返回6
    51 
    52 --floor(x) 小于或等于x的最大值
    53 select floor(5.2) from dual; -- 返回5
    54 
    55 
    56 --  log(x,y) x为低y的对数
    57 select log(2,2) from dual; -- 返回1
    58 
    59 --  mod(x,y) x除以y的余数
    60 select mod(2,3) from dual; -- 返回2
    61 
    62 --  power(x,y) x的y次幂
    63 select power(2,3) from dual; -- 返回8
    64 
    65 -- round(x[,y])  x在第y位四舍五入 
    66 --y默认为0,如果y为负数,小数点右边截补0 ,如果y为正数,小数点左边截 ,
    67 select round(2.2160,2) from dual; -- 返回2.22
    68 
    69 -- sqrt(x)  x的平方根
    70 select sqrt(4) from dual; -- 返回2
    71 
    72 -- trunc(x[,y]) x在第y位截断; 不四舍五入。
    73 --y默认为0,如果y为负数,小数点右边截补0 ,如果y为正数,小数点左边截 ,
    74 select trunc(334.255,-1) from dual; -- 返回330
  • 相关阅读:
    思考未来--马云说:30年后的世界不属于互联网公司
    公司管理系列--Facebook是如何营造企业文化的[转]
    公司管理系列--摒弃“学生思维”,教你如何科学地步入互联网职场?[转]
    问题集录--如何本地调试微信接口(未测试)
    公司管理系列--80% of Your Culture is Your Founder(FaceBook)
    常用工具说明--Mockplus,简洁的原形图设计工具
    你应该知道的计算机网络知识
    【转】TCP那些事(上,下)
    【转】由浅入深探究mysql索引结构原理、性能分析与优化
    【转】程序员技术练级攻略
  • 原文地址:https://www.cnblogs.com/GreenCode/p/7624926.html
Copyright © 2011-2022 走看看