码迷,mamicode.com
首页 > 其他好文 > 详细

不常用函数总结

时间:2017-10-29 11:11:13      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:system   gre   trail   字符串   大小   log   select   varchar   trim   

1.vsize(x) 
返回X的大小(字节)数 
SQL> select vsize(user),user from dual; 
VSIZE(USER) USER 
----------- ------------------------------ 
6 SYSTEM 

2.uid 
返回标识当前用户的唯一整数 
sys用户:
SQL> select username,user_id from dba_users where user_id=uid;
 
USERNAME                          USER_ID
------------------------------ ----------
SYS   

普通用户:
SQL> select username,user_id from user_users where user_id=uid;
 
USERNAME                          USER_ID
------------------------------ ----------
CMS0322_CN                            529

3.soundex 
返回一个与给定的字符串读音相同的字符串 
SQL> create table table1(xm varchar(8)); 
SQL> insert into table1 values(weather); 
SQL> insert into table1 values(wether); 
SQL> insert into table1 values(hbq);
SQL> select xm from table1 where soundex(xm)=soundex(wether);
 
XM
--------
weather
wether

4.ltrim和rtrim 
ltrim 删除左边出现的字符串 
rtrim 删除右边出现的字符串 
SQL> select ltrim(,huangbiquan,,) from dual;
 
LTRIM(,HUANGBIQUAN,,)
--------------------------------
huangbiquan

SQL> select rtrim(huangbiquan,,,) from dual;
 
RTRIM(HUANGBIQUAN,,,)
--------------------------------
huangbiquan

5.trim(s from string) 
leading 剪掉前面的字符 
trailing 剪掉后面的字符 
如果不指定,默认为空格符 
SQL> select trim(  from  huangbiquan ) from dual;
 
TRIM(‘‘FROMHUANGBIQUAN)
--------------------------------
huangbiquan

6.concat 
连接两个字符串; 
SQL> select concat(135,10125049) from dual;
 
CONCAT(135,10125049)
--------------------------------------------------------------------------------
13510125049

select 135||10125049 from dual;
 
135||10125049
----------------------------------------------------------------
13510125049

7.判断x的正负
 
 sign(x)=1     x是正  
        -1     x是负 
        0      x是0  

SQL> select sign(3) from  dual;
 
   SIGN(3)
----------
         1
 
SQL> select sign(0) from  dual;
 
   SIGN(0)
----------
         0
 
SQL> select sign(-8) from  dual;
 
  SIGN(-8)
----------
        -1
        
8.混合函数
--1.求最大值:greatest
SQL> select greatest(100,90,80,101,01,19) from dual; 
 
GREATEST(100,90,80,101,1,19)
----------------------------
                         101
 
SQL> select greatest(b,bc,da,aaaa,aa) from dual;
 
GREATEST(B,BC,DA,AAAA,AA)
--------------------------------
da

--2.求最小值 
SQL> select least(100,0,-9,10) from dual;
 
LEAST(100,0,-9,10)
------------------
                -9
 
SQL> select least(b,bc,da,aaaa,aa) from dual;
 
LEAST(B,BC,DA,AAAA,AA)
--------------------------------
aa

 

不常用函数总结

标签:system   gre   trail   字符串   大小   log   select   varchar   trim   

原文地址:http://www.cnblogs.com/huangbiquan/p/7749435.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!