![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
oralce
毛公鼎
十年磨一剑,千年出一鼎。
展开
-
ORACLE中查询及删除重复记录的方法一
以学生表student为例要去掉重名的人。用rowid方法 查询有重复的记录: select name from student group by name having count(name) > 1; 删除重复的记录,只留有rowid最小的记录 delete from student ...原创 2018-09-03 14:13:21 · 211 阅读 · 0 评论 -
oracle中的exists 和not exists 用法详解以及与in的比较
有两个简单例子,以说明 “exists”和“in”的效率问题1) select * from T1 where exists(select 1 from T2 where T1.a=T2.a) ; T1数据量小而T2数据量非常大时,T1<<T2 时,1) 的查询效率高。2) select * from T1 where T1.a in (s...原创 2019-01-04 10:04:35 · 1323 阅读 · 0 评论 -
解决UNION ALL 字符集不匹配
oralce 在使用union all,如以下SQL时,会出现"字符集不匹配"错误select a.x as x, a.y as y, a.z as z from a union allselect ' ' as x, ' ' as y, b.z as z from b; 解决办法:都用to_char转成字符串select to_char(a.x) as x, ...原创 2019-01-16 15:31:14 · 6661 阅读 · 1 评论 -
数据库类型varchar和nvarchar的区别
(1) varchar(n)长度为 n 个字节的可变长度且非 Unicode 的字符数据。 n 必须是一个介于 1 和 8,000 之间的数值。存储大小为输入数据的字节的实际长度,而不是 n 个字节。 (2) nvarchar(n)包含 n 个字符的可变长度 Unicode 字符数据。 ...原创 2019-02-14 17:09:38 · 8783 阅读 · 0 评论 -
ORA-01830: 日期格式图片在转换整个输入字符串之前结束
plsql报错如下图:表中实际存的时间为varchar2,且是yyyy-MM-dd格式。所以在to_date转换的时候不能to_date(t.create_time,'yyyy-MM'),而是要用to_date(t.create_time,'yyyy-MM-dd').报错原因是字符串的精确度与转换时间格式没有对应。截取start_date年月日部分使用 select ...原创 2019-03-14 11:46:10 · 10630 阅读 · 0 评论 -
CASE WHEN 及 SELECT CASE WHEN的用法
Case具有两种格式。简单Case函数和Case搜索函数。简单Case函数CASEsexWHEN'1'THEN'男'WHEN'2'THEN'女'ELSE'其他'END--Case搜索函数CASEWHEN sex ='1'THEN'男'WHEN sex ='2'THEN'女'ELSE'其他'END种方式,...原创 2019-05-09 15:03:55 · 196 阅读 · 0 评论 -
oracle的sql中将字符串数字转换成数字
select '15.5' as str from dual;select '15.5' + 0 as str from dual;select * from sys_resource order by id+0;--id数据类型是 varchar2select cast('15.5678' as decimal(6,2)) as num from dual;select t...原创 2019-06-05 10:39:11 · 22147 阅读 · 0 评论 -
oracle中数字处理函数
数字函数1,取整函数(ceil 向上取整,floor 向下取整) select ceil(66.6) N1,floor(66.6) N2 from dual;2, 取幂(power) 和 求平方根(sqrt) select power(3,2) N1,sqrt(9) N2 from dual;3,求余 select mod(9,5) from dual;...原创 2019-06-17 15:50:08 · 556 阅读 · 0 评论 -
oracle中数字转字符少0的各种情况
出现####的原因是因为'99D99'中第一个99表示最大值,超过99就失败了。所以一定要调整到合适的最大值。小数点后面也缺失,所以D后面也是要加99个位数必须是0,不然就会丢掉个位的0....原创 2019-06-17 16:45:42 · 4505 阅读 · 0 评论