oracle函数方法(虚拟表操作)
2015-04-08 10:24
225 查看
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;
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;
相关文章推荐
- 在使用win 7 无线承载网络时,启动该服务时,有时会提示:组或资源的状态不是执行请求操作的正确状态。 网上有文章指出,解决这个问题的方法是在设备管理器中启动“Microsoft托管网络虚拟适配
- 虚拟主机无法使用fsockopen操作处理方法
- 虚拟主机用户ftp和apache用户文件互操作权限解决方法
- 虚拟主机用户ftp和apache用户文件互操作权限解决方法
- VC 7.0 中使用CDaoRecordset 类/使用Dao 方法操作数据库
- ASP.NET对IIS中的虚拟目录进行操作
- Java操作Excel的一种方法
- 常用的操作xml文档的方法
- 企业集中管理方法:组策略的操作
- ASP通过XMLDom在服务器端操作XML文件的主要方法和实现。
- 对虚拟目录的操作
- java操作Excel的一种方法
- 在WinFrom应用中,如果使用后台线程来操作界面应调用Control.Invoke()方法
- Tomcat5.x中的虚拟主机配置方法
- C++、Java和C#语言在处理“虚拟私有方法”上的差异
- 在Asp.net中操作IIS的虚拟目录(C#)
- 解决ASP 2.0中GridView控件的删除、插入、编辑命令操作客户端确认问题的另一方法
- .net下操作Excel数据的几种方法
- 通知php使用自定义的session处理函数来操作session,而不使用php预置的方法
- Tomcat5.x中的虚拟主机配置方法