- 1、本文档共8页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Oracle笔记 三、function 、select
Scott表下有这么几个常用的表,而且还带有数据。分别是emp、dept、salgrade;
1、查看表结构用desc
desc emp;
2、空表dual,最常用的空表,如:
select 2 * 4 from dual;
select sysdate from dual;
3、双引号能保持格式
如:select sysdate “toDay 日 期” from dual;
4、|| 字符串连接
如:select 2*3 || 8 from dual;
select ename || sal from scott.emp;
select ename || ‘ORACLE’ from scott.emp;
5、单引号,如:select 2 * 2 || abcefg from dual;
用两个单引号表示一个单引号
6、去掉重复数据distinct
select distinct deptno from scott.emp;
去掉重复组合:select distinct deptno,job from scott.emp;
7、where查询
A、=查询,select * from scott.emp where sal = 1500;
B、比较、、=、=
select * from scott.emp where sal 1500;
C、and or
select * from scott.emp where sal 1500 and sal = 5000 or deptno = 10;
D、in、not in
select * from scott.emp where sal in (1500, 800) and deptno not in (10, 20)
E、like模糊 escape 转义
Select * from scott.emp where ename like ‘%in%’;
Select * from scott.emp where ename like ‘%in\%k%’;
Select * from scott.emp where ename like ‘%in#%k%’ escape ‘#’;
表示like中的#号是转义字符,相当于\
F、is null、is not null
K、 order by
select sal, ename from scott.emp order by sal;
select sal, ename from scott.emp order by sal asc;
select sal, ename from scott.emp order by sal desc;
select sal, ename from scott.emp where sal 2000 order by sal desc;
select sal, deptno, ename from scott.emp order by sal,deptno desc;
8、function
A、lower、upper、substr
select lower(‘abcABC’) from dual;
select upper(‘abcABC’) from dual;
substr(target, startIndex, length)
select substr(‘abcABC’, 1, 3) from dual;
B、chr、ascii
将数字安装ascii值转换成字符:select char(65) from dual;
将字符转换成ascii值:select ascii(‘Z’) from dual;
C、round、to_char
精确小数
select round(22.456) from dual;
保留2位小数:select round(22.456, 2) from dual;
精确到个位:select round(22.456, -1) from dual;
货币
设置货币格式,00
文档评论(0)