oracle 数据库对象增长记录查询对比语句
2011-12-31 14:11
1011 查看
select *
from (select a.owner,
a.segment_name,
a.tablespace_name,
b.megas - a.megas diff
from (select owner, segment_name, tablespace_name, sum(megas) megas
from object_rd
where to_char(recode_time, 'yyyymmdd') = '20120627'
group by owner, segment_name, tablespace_name) a,
(select owner, segment_name, tablespace_name, sum(megas) megas
from object_rd
where to_char(recode_time, 'yyyymmdd') = '20120628'
group by owner, segment_name, tablespace_name) b
where a.owner = b.owner(+)
and a.segment_name = b.segment_name(+)
--and a.segment_type=b.segment_type
--and a.tablespace_name = b.tablespace_name
union
select b.owner,
b.segment_name,
b.tablespace_name,
b.megas - a.megas diff
from (select owner, segment_name, tablespace_name, sum(megas) megas
from object_rd
where to_char(recode_time, 'yyyymmdd') = '20120626'
group by owner, segment_name, tablespace_name) a,
(select owner, segment_name, tablespace_name, sum(megas) megas
from object_rd
where to_char(recode_time, 'yyyymmdd') = '20120627'
group by owner, segment_name, tablespace_name) b
where a.owner(+) = b.owner
and a.segment_name(+) = b.segment_name
--and a.segment_type=b.segment_type
--and a.tablespace_name = b.tablespace_name
) c
where c.diff > 1 or c.diff is null
order by c.diff desc
------------------------------------------------------------------------------------------------------------------------
select owner,segment_name,tablespace_name,segment_type,diff,flag
from (select a.owner,
a.segment_name,
a.tablespace_name,
a.segment_type,
nvl(b.megas - a.megas,a.megas) diff,
nvl2(b.megas - a.megas,'原有对象','新增或已删除对象') flag
from (select owner, segment_name,segment_type, tablespace_name, sum(megas) megas
from object_rd
where to_char(record_time, 'yyyymmdd') = '20130220'
group by owner, segment_name,segment_type, tablespace_name) a,
(select owner, segment_name,segment_type, tablespace_name, sum(megas) megas
from object_rd
where to_char(record_time, 'yyyymmdd') = '20130221'
group by owner, segment_name, segment_type,tablespace_name) b
where a.owner = b.owner(+)
and a.segment_name = b.segment_name(+)
and a.segment_type=b.segment_type(+)
--and a.tablespace_name = b.tablespace_name
union
select b.owner,
b.segment_name,
b.tablespace_name,
b.segment_type,
nvl(b.megas - a.megas,b.megas) diff,
nvl2(b.megas - a.megas,'原有对象','新增或已删除对象') flag
from (select owner, segment_name,segment_type, tablespace_name, sum(megas) megas
from object_rd
where to_char(record_time, 'yyyymmdd') = '20130220'
group by owner, segment_name, segment_type,tablespace_name) a,
(select owner, segment_name,segment_type, tablespace_name, sum(megas) megas
from object_rd
where to_char(record_time, 'yyyymmdd') = '20130221'
group by owner, segment_name, segment_type,tablespace_name) b
where a.owner(+) = b.owner
and a.segment_name(+) = b.segment_name
and a.segment_type(+)=b.segment_type
--and a.tablespace_name = b.tablespace_name
) c
where c.diff > 0
and segment_name not like '%=$0'
and not exists(select 1 from dba_recyclebin t where t.owner=c.owner and t.original_name=c.segment_name)
order by c.diff desc
from (select a.owner,
a.segment_name,
a.tablespace_name,
b.megas - a.megas diff
from (select owner, segment_name, tablespace_name, sum(megas) megas
from object_rd
where to_char(recode_time, 'yyyymmdd') = '20120627'
group by owner, segment_name, tablespace_name) a,
(select owner, segment_name, tablespace_name, sum(megas) megas
from object_rd
where to_char(recode_time, 'yyyymmdd') = '20120628'
group by owner, segment_name, tablespace_name) b
where a.owner = b.owner(+)
and a.segment_name = b.segment_name(+)
--and a.segment_type=b.segment_type
--and a.tablespace_name = b.tablespace_name
union
select b.owner,
b.segment_name,
b.tablespace_name,
b.megas - a.megas diff
from (select owner, segment_name, tablespace_name, sum(megas) megas
from object_rd
where to_char(recode_time, 'yyyymmdd') = '20120626'
group by owner, segment_name, tablespace_name) a,
(select owner, segment_name, tablespace_name, sum(megas) megas
from object_rd
where to_char(recode_time, 'yyyymmdd') = '20120627'
group by owner, segment_name, tablespace_name) b
where a.owner(+) = b.owner
and a.segment_name(+) = b.segment_name
--and a.segment_type=b.segment_type
--and a.tablespace_name = b.tablespace_name
) c
where c.diff > 1 or c.diff is null
order by c.diff desc
------------------------------------------------------------------------------------------------------------------------
select owner,segment_name,tablespace_name,segment_type,diff,flag
from (select a.owner,
a.segment_name,
a.tablespace_name,
a.segment_type,
nvl(b.megas - a.megas,a.megas) diff,
nvl2(b.megas - a.megas,'原有对象','新增或已删除对象') flag
from (select owner, segment_name,segment_type, tablespace_name, sum(megas) megas
from object_rd
where to_char(record_time, 'yyyymmdd') = '20130220'
group by owner, segment_name,segment_type, tablespace_name) a,
(select owner, segment_name,segment_type, tablespace_name, sum(megas) megas
from object_rd
where to_char(record_time, 'yyyymmdd') = '20130221'
group by owner, segment_name, segment_type,tablespace_name) b
where a.owner = b.owner(+)
and a.segment_name = b.segment_name(+)
and a.segment_type=b.segment_type(+)
--and a.tablespace_name = b.tablespace_name
union
select b.owner,
b.segment_name,
b.tablespace_name,
b.segment_type,
nvl(b.megas - a.megas,b.megas) diff,
nvl2(b.megas - a.megas,'原有对象','新增或已删除对象') flag
from (select owner, segment_name,segment_type, tablespace_name, sum(megas) megas
from object_rd
where to_char(record_time, 'yyyymmdd') = '20130220'
group by owner, segment_name, segment_type,tablespace_name) a,
(select owner, segment_name,segment_type, tablespace_name, sum(megas) megas
from object_rd
where to_char(record_time, 'yyyymmdd') = '20130221'
group by owner, segment_name, segment_type,tablespace_name) b
where a.owner(+) = b.owner
and a.segment_name(+) = b.segment_name
and a.segment_type(+)=b.segment_type
--and a.tablespace_name = b.tablespace_name
) c
where c.diff > 0
and segment_name not like '%=$0'
and not exists(select 1 from dba_recyclebin t where t.owner=c.owner and t.original_name=c.segment_name)
order by c.diff desc
相关文章推荐
- MySQL、SQL Server、Oracle 3种数据库查询表中前N行记录的SQL语句
- 不同数据库oracle mysql SQL Server DB2 infomix sybase分页查询语句
- 如何得到JDBC Insert 语句执行后插入Oracle 数据库记录的主键
- 数据库Oracle、Sql Server单表树形结构数据查询语句
- 用SQL语句查询数据库中某一字段下相同值的记录方法
- Oracle 查询并删除重复记录的SQL语句
- Oracle 删除重复数据只留一条 查询及删除重复记录的SQL语句 1、查找表中多余的重复记录,重复记录是根据单个字段(Id)来判断 select * from 表 wher
- sql语句查询数据库中的表名/列名/主键/自动增长值实例
- Oracle 查询并删除重复记录的SQL语句
- 如何得到JDBC Insert 语句执行后插入Oracle 数据库记录的主键
- 终极解决sqlserver、MySQL、Oracle三种数据库模糊查询语句,ssm框架mybatis操作数据库
- 如何估算oracle 数据库,数据库对象历史增长情况
- Oracle数据库快速查询重复记录的方法;
- [Oracle]客户端查询数据库最近执行的SQL语句
- oracle中查询和定位数据库问题的SQL语句
- Oracle 查询并删除重复记录的SQL语句
- 如何使用Oracle查询并删除重复记录的SQL语句
- oracle数据库常用的99条查询语句
- 各种数据库(MYSQL、Oracle、DB2、SQL Server、PostgreSQL)的分页查询语句
- 终极解决sqlserver、MySQL、Oracle三种数据库模糊查询语句,ssm框架mybatis操作数据库