Oracle常见函数

前端之家收集整理的这篇文章主要介绍了Oracle常见函数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


1.LENGTH() 长度

select length(id) from merchant where id=221;
3

2.REPLACE(,[,]) 替换

c1,c2,c3都是字符串,函数用c3代替出现在c1中的c2后返回。

select REPLACE('uptown','up','down') from dual

downtown

3.SUBSTR(,<i>[,]) 截取

c1为一字符串,i,j为整数,从c1的第i位开始返回长度为j的子字符串,如果j为空,则直到串的尾部。
select SUBSTR(id,1,2) from merchant where id=221;
select SUBSTR(id,2,2) from merchant where id=221;

22
21

4.SYADATE

函数没有参数,返回当前日期和时间。

select sysdate from dual;

5.TO_CHAR([[,)和TO_DATE([,)

select * from wechat_trans_info where trans_status =? and to_char(trans_time,'yyyy-MM-dd') = ? and acq_enname='SPD' order by trans_time ";
		Object[] params = {"SUCCESS",transDate};
		return dao.find(WechatTransInfo.class,sql,params);



and sai.create_time >= to_date (?,'yyyy-MM-dd hh24:mi:ss') 

6.

UID
该函数没有参数,返回唯一标示当前数据库用户的整数。
select uid from dual;
121

USER
返回当前用户用户名
select user from dual;
QRPAY

7.trunc

select trunc(sysdate)-1 from dual;

2017/6/29 
今天为2017/6/30,获得的是昨天的日期



8.round 保留几位小数

wechat_merchant_rate=0.002 
select round(wechat_merchant_rate,2) from wechat_merchant where id=869;select round(wechat_merchant_rate,3) from wechat_merchant where id=869;0.000.002
原文链接:https://www.f2er.com/oracle/208706.html

猜你在找的Oracle相关文章