oracle学习实践记录2.pdf

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:750

[size=14px][backcolor=inherit][backcolor=inherit][size=22px]字符函数
[backcolor=inherit]SQL> select chr(97),ascii('A') FROM DUAL;
[backcolor=inherit]CHR(97) ASCII('A')
[backcolor=inherit]------- ----------
[backcolor=inherit]a 65

[backcolor=inherit]SQL>

[size=14px][backcolor=inherit]SQL> [backcolor=inherit]SELECT INITCAP('abcd') as 首字母大写,LOWER('ABcdEF') as 全小写,UPPER('ABcdEF') as 全大写 from dual;
[backcolor=inherit]INITCAP('ABCD') LOWER('ABCDEF') UPPER('ABCDEF')
[backcolor=inherit]--------------- --------------- ---------------
[backcolor=inherit][backcolor=rgb(255, 0, 0)]Abcd [backcolor=rgb(255, 255, 0)] abcdef [backcolor=rgb(195, 214, 155)] ABCDEF

[backcolor=inherit]SQL>

[size=14px][backcolor=inherit]SQL> select empno,ename,hiredate,[backcolor=rgb(255, 0, 0)]SUBSTR(hiredate,8,2) AS year
[backcolor=inherit] 2 from scott.emp ORDER BY year ASC;
[backcolor=inherit]EMPNO ENAME HIREDATE YEAR
[backcolor=inherit]----- ---------- ----------- --------
[backcolor=inherit] 7369 SMITH 1980/12/17 80
[backcolor=inherit] 7782 CLARK 1981/6/9 81
[backcolor=inherit] 7902 FORD 1981/12/3 81
[backcolor=inherit] 7900 JAMES 1981/12/3 81
[backcolor=inherit] 7844 TURNER 1981/9/8 81
[backcolor=inherit] 7499 ALLEN 1981/2/20 81
[backcolor=inherit] 7521 WARD 1981/2/22 81
[backcolor=inherit] 7566 JONES 1981/4/2 81
[backcolor=inherit] 7654 MARTIN 1981/9/28 81
[backcolor=inherit] 7698 BLAKE 1981/5/1 81
[backcolor=inherit] 7935 S%F 1981/1/3 81
[backcolor=inherit] 7839 KING 1981/11/17 81
[backcolor=inherit] 7934 MILLER 1982/1/23 82
[backcolor=inherit] 7876 ADAMS 1987/5/23 87
[backcolor=inherit] 7788 SCOTT 1987/4/19 87
[backcolor=inherit] 7933 Candy
[backcolor=inherit]16 rows selected

[backcolor=inherit]SQL>

[size=14px][backcolor=inherit][backcolor=rgb(149, 179, 215)]SQL> select empno,ename,hiredate,UPPER(ename) 大写,LOWER(ename) 小写,
[backcolor=inherit][backcolor=rgb(149, 179, 215)] 2 LPAD(ename,10,'love') 左边填充,RPAD(ename,[backcolor=inherit]10,'love') 右边填充
[backcolor=inherit][backcolor=rgb(149, 179, 215)] 3 from scott.emp;(10为填充后的字符总数)
[backcolor=inherit][backcolor=rgb(149, 179, 215)]EMPNO ENAME HIREDATE 大写 小写 左边填充 右边填充
[backcolor=inherit][backcolor=rgb(149, 179, 215)]----- ---------- ----------- ---------- ---------- ---------------------------------------- ----------------------------------------
[backcolor=inherit][backcolor=rgb(149, 179, 215)] 7933 Candy CANDY candy lovelCandy Candylovel
[backcolor=inherit][backcolor=rgb(149, 179, 215)] 7369 SMITH 1980/12/17 SMITH smith lovelSMITH SMITHlovel
[backcolor=inherit][backcolor=rgb(149, 179, 215)] 7499 ALLEN 1981/2/20 ALLEN allen lovelALLEN ALLENlovel
[backcolor=inherit][backcolor=rgb(149, 179, 215)] 7521 WARD 1981/2/22 WARD ward loveloWARD WARDlovelo
[backcolor=inherit][backcolor=rgb(149, 179, 215)] 7566 JONES 1981/4/2 JONES jones lovelJONES JONESlovel
[backcolor=inherit][backcolor=rgb(149, 179, 215)] 7654 MARTIN 1981/9/28 MARTIN martin loveMARTIN MARTINlove
[backcolor=inherit][backcolor=rgb(149, 179, 215)] 7698 BLAKE 1981/5/1 BLAKE blake lovelBLAKE BLAKElovel
[backcolor=inherit][backcolor=rgb(149, 179, 215)] 7782 CLARK 1981/6/9 CLARK clark lovelCLARK CLARKlovel
[backcolor=inherit][backcolor=rgb(149, 179, 215)] 7788 SCOTT 1987/4/19 SCOTT scott lovelSCOTT SCOTTlovel
[backcolor=inherit][backcolor=rgb(149, 179, 215)] 7839 KING 1981/11/17 KING king loveloKING KINGlovelo
[backcolor=inherit][backcolor=rgb(149, 179, 215)] 7844 TURNER 1981/9/8 TURNER turner loveTURNER TURNERlove
[backcolor=inherit][backcolor=rgb(149, 179, 215)] 7876 ADAMS 1987/5/23 ADAMS adams lovelADAMS ADAMSlovel
[backcolor=inherit][backcolor=rgb(149, 179, 215)] 7900 JAMES 1981/12/3 JAMES james lovelJAMES JAMESlovel
[backcolor=inherit][backcolor=rgb(149, 179, 215)] 7902 FORD 1981/12/3 FORD ford loveloFORD FORDlovelo
[backcolor=inherit][backcolor=rgb(149, 179, 215)] 7934 MILLER 1982/1/23 MILLER miller loveMILLER MILLERlove
[backcolor=inherit][backcolor=rgb(149, 179, 215)] 7935 S%F 1981/1/3 S%F s%f lovelovS%F S%Flovelov
[backcolor=inherit][backcolor=rgb(149, 179, 215)]16 rows selected
[backcolor=inherit][backcolor=rgb(149, 179, 215)]

[backcolor=inherit][backcolor=rgb(149, 179, 215)]SQL>

[size=14px][backcolor=inherit]select empno,ename,hiredate,UPPER(ename) 大写,LOWER(ename) 小写, INITCAP(ename) 第一个字母大写,
[backcolor=inherit]LPAD(ename,10,'love') 左边填充,RPAD(ename,10,'love') 右边填充,LTRIM(ename,'A') 删除左边A字母,
[backcolor=inherit]RTRIM(ename,'dy') 删除右边dy字母,REPLACE(ename,'SM','[backcolor=rgb(255, 0, 0)]HI') 查找替换,LENGTH(ename) ename长度,
[backcolor=inherit]SUBSTR(empno,3,2) 获取2个
[backcolor=inherit]from scott.emp;

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】