温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Oracle 数据库入门之----------------------单行函数

发布时间:2020-06-27 16:04:57 来源:网络 阅读:181 作者:wuyi0706 栏目:云计算

1,单行函数

SQL> --字符函数

SQL> select lower('Hello World') 转小写,upper('Hello World') 转大写,initcap('hello world') 首字母大写

2 from dual;

转小写 转大写 首字母大写


hello world HELLO WORLD Hello World

SQL> --substr(a,b) 从a中,第b位开始取

SQL> select substr('Hello World',4) 子串 from dual;

子串


lo World

SQL> --substr(a,b,c) 从a中,第b位开始取,取c位

SQL> select substr('Hello World',4,3) 子串 from dual;


lo

SQL> --length 字符数 lengthb 字节数

SQL> select length('Hello World') 字符,lengthb('Hello World') 字节 from dual;

  字符       字节                                                           

    11         11                                                           

SQL> ed

已写入 file afiedt.buf

1* select length('北京') 字符,lengthb('北京') 字节 from dual

SQL> /

  字符       字节                                                           

     2          4                                                           

SQL> --instr(a,b)

SQL> --在a中,查找b

SQL> select instr('Hello World','ll') 位置 from dual;

  位置                                                                      

     3                                                                      

SQL> --lpad 左填充 rpad 右填充

SQL> -- abcd ---> 10位

SQL> select lpad('abcd',10,'') 左,rpad('abcd',10,'') 右 from dual;

左 右


**abcd abcd**

SQL> --trim 去掉前后指定的字符

SQL> select trim('H' from 'Hello WorldH') from dual;

TRIM('H'FR


ello World

SQL> --replace

SQL> select replace('Hello World','l','*') from dual;

REPLACE('HE


He*o Word

SQL> host cls

SQL> --四舍五入

SQL> select round(45.926,2) 一,round(45.926,1) 二,round(45.926,0) 三,round(45.926,-1) 四,round(45.926,-2) 五

2 from dual;

    一         二         三         四         五                          

 45.93       45.9         46         50          0                          

SQL> --截断

SQL> ed

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI