• oracle函数方法(虚拟表操作)


    select initcap('smith') upp from dual; --首字母大写 initcap()
    select concat('111','222')||'333' 电话 from dual ; --连接字符串方法 concat(,)
    select '111222'||'333'  电话 from dual;
    select instr('oracleeetraning','ra',1,1) instring from dual;select instr('oracleeetraning','ra',1,2) instring from dual;
    --在一个字符串中搜索指定的字符,返回发现指定的字符的位置;
    --INSTR(C1,C2,I,J)  C1被搜索的字符串  C2希望搜索的字符串  I搜索的开始位置,默认为1  J出现的位置,默认为1
    select lower('AaBbCcDd')AaBbCcDd from dual;
    select upper('AaBbCcDd') upper from dual;
    select lpad(rpad('gao',10,'*'),17,'*') ds from dual; --不够字符用*代替
    select ltrim(rtrim('   gao qian jing   ',' '),' ') from dual;--LTRIM  删除左边出现的字符串  RTRIM  删除右边出现的字符串
    select substr('13088888888',3,8) from dual;--取子字符串,从start开始,取count个
    select replace('he love you','he','i') from dual;--string   希望被替换的字符或变量 s1被替换的字符串  s2要替换的字符串
    -----------------------新鲜(不过不支持中文)---------------------
    --返回一个与给定的字符串读音相同的字符串
    create table table1(xm varchar(8));
    insert into table1 values('weather');
    insert into table1 values('wether');
    insert into table1 values('gao');
    select xm from table1 where soundex(xm)=soundex('weather');
    ------------------------------------------------
    select abs(100),abs(-100) from dual;--返回绝对值
    select ceil(3.1415927) from dual;--返回大于或等于给出数字的最小整数
    select floor(2345.67) from dual;--对给定的数字取整数
    select round(55.5),round(-55.4),trunc(55.5),trunc(-55.5) from dual;--按指定精度取值
    select sign(123),sign(-100),sign(0) from dual;--取数字n的符号,大于0返回1,小于0返回-1,等于0返回0
    select trunc(124.1666,-2) trunc1,trunc(124.16666,2) from dual;--按照指定的精度截取一个数 trunc截图
    select to_char(add_months(to_date('199912','yyyymm'),2),'yyyymm') from dual;--增加或减去月份
    select last_day(sysdate) from dual; --返回日期的最后一天
    select sysdate from dual;           --返回系统日期的最后一天
    select months_between('19-12月-1999','19-3月-1999') mon_between from dual;--给出date1-date2的月份
    select months_between(to_date('2000.05.20','yyyy.mm.dd'),to_date('2005.05.20','yyyy.mm.dd')) mon_betw from dual;
    select to_char(sysdate,'yyyy.mm.dd hh24:mi:ss') bj_time,to_char(new_time(sysdate,'PDT','GMT'),'yyyy.mm.dd hh24:mi:ss') los_angles from dual;
    select next_day('18-5月-2001','星期五') next_day from dual;--给出日期date和星期x之后计算下一个星期的日期
    select to_char(sysdate,'yyyy-mm-dd day') from dual;--获得系统当前日期 可获得星期
    select to_char(trunc(sysdate,'hh'),'yyyy.mm.dd hh24:mi:ss') hh,to_char(trunc(sysdate,'mi'),'yyyy.mm.dd hh24:mi:ss') hhmm from dual;
    --trunc(date,fmt)按照给出的要求将日期截断,如果fmt='mi'表示保留分,截断秒
    select to_number('19909') year from dual;--将给出的字符转换为数字
    select userenv('isdba') from dual;
    select userenv('sessionid') from dual;--返回会话标志
    select userenv('language') from dual;
    select userenv('lang') from dual;
    select userenv('terminal') from dual;--返回用户的终端或机器的标志
    --AVG(DISTINCT|ALL)
    --all表示对所有的值求平均值,distinct只对不同的值求平均值 --select avg(distinct sal) from gao.table3; --select avg(all sal) from gao.table3;


  • 相关阅读:
    laravel 资源控制器方法列表
    laravel 用户认证简单示例
    使用Faker库生成模拟数据
    js获取世界不同时区的当前时间
    html2canvas将页面内容生成图片
    canvas绘制环形进度条
    H5 实现图片上传预览
    js实现复制内容到粘贴板
    node.js创建简单服务测试请求数据
    ES6语法知识
  • 原文地址:https://www.cnblogs.com/yangmin-78819/p/4401695.html
Copyright © 2020-2023  润新知