不常用函数总结
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了不常用函数总结相关的知识,希望对你有一定的参考价值。
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(‘‘FROM‘HUANGBIQUAN‘) -------------------------------- 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
以上是关于不常用函数总结的主要内容,如果未能解决你的问题,请参考以下文章