oracle 开发
winer1220
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
NOT IN的坑——子查询含空值
一:环境 SQL> select * from v$version; BANNER ---------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production P...原创 2020-02-01 19:55:18 · 643 阅读 · 0 评论 -
Oracle 数据排序——按照 IN 列表位置
通常排序按照值大小排序,但有时候也有例外的时候,比如按照IN 列表位置排序。 SQL> create table tt(id number(5)); Table created. SQL> insert into tt values(1); 1 row created. SQL> insert into tt values(3); 1 row created....原创 2018-12-06 09:59:51 · 4323 阅读 · 0 评论 -
Oracle 周相关函数
select trunc(sysdate,’W’), –每月1日作为第一个星期第一天 取当前周第一天对应日期 trunc(sysdate,’WW’), –每年1月1日作为第一个新奇第一天,取当前周对应第一天日期 trunc(sysdate,’IW’), –当前日期的周一对应日期(自然周) to_char(sysdate,’W’), –每月1日为...原创 2018-08-12 21:42:42 · 6657 阅读 · 0 评论 -
聚集因子 cluster factor
一:what 1: 聚集因子 是索引数据顺序和表顺序的一致性 2: 取值范围为:最小数据块数,最大为行数,值越小越好! 二:why 1:聚集因子会影响sql的执行效率 2:比如表结构,数据量,索引都一样,生产和测试环境sql执行效率大不一致, 这种情况下就可能是聚集因子不一致导致的 三:how drop table t_test; create table t_t...原创 2018-06-14 17:12:55 · 1434 阅读 · 0 评论 -
count大揭秘
1:count(*) 和count(常量)统计所有行 count(常量)相当于每行增加一个常量字段 2:count(列名) 统计此列是非空的行 3:count(null) 恒等于 0 SQL> create table t1 as select * from dba_objects; 表已创建。 SQL> --统计所有行 SQL> select count(*) fro原创 2018-02-01 22:13:32 · 190 阅读 · 0 评论 -
oracle 创建临时表问题实战案例一
drop table tmp_t1; create global temporary table tmp_t1 as select * from dba_objects where rownum <= 10; select count(*) from tmp_t1; 一:分析问题 1:现象: 这里创建了临时表t1,临时表却没有数据。 2:分析: 是因为如果不指定临原创 2015-09-01 11:29:40 · 392 阅读 · 0 评论 -
分析函数及窗口函数(一)
分析函数格式(三部分组成) 函数名(参数) over(partition by 子句 order by 子句 rows/range子句) 三部分组成 1: 函数名 比如:sum,avg,max,min等聚合函数或lead,lag行比较函数 2: over 关键字,说明是分析函数 3: 分析子句 over括号内的内容,原创 2014-08-19 15:17:23 · 413 阅读 · 0 评论 -
oracle IN 变量多值处理方法——(instr)
declare v_mech VARCHAR2(20); v_cnt NUMBER(20); begin v_mech := '''a'''||','||'''b'''; with tt(tid,tname) as ( select 1,'a' from dual union all原创 2014-08-15 14:38:04 · 2735 阅读 · 0 评论 -
动态sql中时间处理
动态sql中,需要使用时间条件,是比较麻烦: 如果条件相对固定,用绑定变量,当然是最好的,特别是在oltp系统中,这种是最好的,推荐使用 如果条件很灵活(绑定变量的数量不好确定)或olap系统,用动态拼接就是不错的选择 create">USER1@TEST>create table t1(id number,tdate date); 表已创建。 USER1@TEST> in原创 2013-11-26 11:03:13 · 252 阅读 · 0 评论 -
trunc()函数使用
--Oracle trunc()函数的用法 /**************日期********************/ /* TRUNC(date[,fmt]) date 时间 fmt 日期格式,不支持组合时间格式,如yyyy-MM-dd等格式 没有fmt,则默认为当前日期,没有时间 */ --1. 2013-11-26 今天的日期为 selec原创 2013-11-26 11:50:03 · 297 阅读 · 0 评论 -
oracle 的rowtype使用
oracle 中%ROWTYPE的使用 1:table_name%ROWTYPE declare v_t1 t1%rowtype; begin select tid,tname into v_t1 from t1 where tid = 1; dbms_output.put_line(v_t1.tid || ' -- '||v_t1.t原创 2013-10-16 11:07:16 · 933 阅读 · 0 评论
分享