一次oracle迁移11g到19c后用到的对象数量对比脚本

一次oracle迁移11g到19c后用到的对象数量对比脚本,按用户习惯就好。

oracle@jyc:/home/oracle/stat>ll

合計 584

-rw-r--r-- 1 oracle oinstall 82709 9月 27 09:20 11g-79-01.txt

-rw-r--r-- 1 oracle oinstall 332 9月 27 09:17 11g-79-02.txt

-rw-r--r-- 1 oracle oinstall 161788 9月 27 09:17 11g-79-03.txt

-rw-r--r-- 1 oracle oinstall 721 9月 27 09:07 o1.bak

-rw-r--r-- 1 oracle oinstall 25878 9月 27 09:20 o1.log

-rwxr-xr-x 1 oracle oinstall 335 9月 27 09:07 o1.sh

-rw-r--r-- 1 oracle oinstall 809 9月 27 09:18 o1.sql

-rw-r--r-- 1 oracle oinstall 82659 9月 27 09:20 o1.txt

-rw-r--r-- 1 oracle oinstall 492 9月 27 09:17 o2.log

-rwxr-xr-x 1 oracle oinstall 134 9月 27 09:07 o2.sh

-rw-r--r-- 1 oracle oinstall 655 9月 27 09:15 o2.sql

-rw-r--r-- 1 oracle oinstall 29932 9月 27 09:17 o3.log

-rwxr-xr-x 1 oracle oinstall 317 9月 27 09:07 o3.sh

-rw-r--r-- 1 oracle oinstall 1570 9月 27 12:01 o3.sql

-rw-r--r-- 1 oracle oinstall 161756 9月 27 09:17 o3.txt

oracle@jyc:/home/oracle/stat>more o1.sh

#!/bin/bash

sqlplus system/oracle <<EOF

spool /home/oracle/stat/o1.txt;

set timing on

@/home/oracle/stat/o1.sql;

spool off;

exit;

EOF

echo "OWNER TABLESPACE_NAME TABLE_NAME ROW_COUNT TABLE_SIZE(M)" | cat - /home/oracle/stat/o1.txt |grep -v "SQL>" > /home/oracle/stat/o11.txt

oracle@jyc:/home/oracle/stat>more o1.sql

set pagesize 0

set line 180

--set head on

col OWNER for a10

col TABLESPACE_NAME for a32

col table_name for a40

col ROW_COUNT for 9999999999999999

col TABLE_SIZE(M) for a30

SELECT T.OWNER,

T.TABLESPACE_NAME,

T.table_name,

to_number(extractvalue(xmltype(dbms_xmlgen.getxml('select count(*) c from ' || T.OWNER ||'.' || T.TABLE_NAME)),

'/ROWSET/ROW/C')) AS row_count,

(select trim(to_char(round(sum(bytes) / (1024 * 1024), 4),

'999990.9999')) || 'M' as M

from dba_segments

where segment_name = upper(t.TABLE_NAME)) as "TABLE_SIZE(M)"

FROM dba_tables T

WHERE T.OWNER IN ('JYC1','JYC2')

ORDER BY T.OWNER, T.TABLESPACE_NAME, T.TABLE_NAME;

oracle@jyc:/home/oracle/stat>more o2.sh

#!/bin/bash

sqlplus system/oracle <<EOF

spool /home/oracle/stat/o2.txt;

set timing on

@/home/oracle/stat/o2.sql;

spool off;

exit;

EOF

oracle@jyc:/home/oracle/stat>more o2.sql

set head on

SELECT

(SELECT COUNT(*) FROM dba_tables where owner in ('JYC1','JYC2')) AS table_count,

(SELECT COUNT(*) FROM dba_views where owner in ('JYC1','JYC2')) AS view_count,

(SELECT COUNT(*) FROM dba_procedures where owner in ('JYC1','JYC2')) AS procedure_count,

(SELECT COUNT(*) FROM dba_triggers where owner in ('JYC1','JYC2')) AS trigger_count

FROM

dual;

oracle@jyc:/home/oracle/stat>more o3.sh

#!/bin/bash

sqlplus system/oracle <<EOF

spool /home/oracle/stat/o3.txt;

set timing on

@/home/oracle/stat/o3.sql;

spool off;

exit;

EOF

echo "用户 对象类型 对象名称 对象表空间" | cat - /home/oracle/stat/o3.txt |grep -v "SQL>" > /home/oracle/stat/o31.txt

oracle@jyc:/home/oracle/stat>more o3.sql

set head on

set pagesize 0

set line 180

col 用户 for a10

col 对象类型 for a20

col 对象名称 for a40

col 对象表空间 for a32

SELECT ss.用户, ss.对象类型, ss.对象名称, ss.对象表空间

FROM (SELECT 'table' as 对象类型,

t.OWNER as 用户,

t.TABLESPACE_NAME as 对象表空间,

t.TABLE_NAME as 对象名称

FROM dba_tables t where t.owner in ('JYC1','JYC2')

union all

SELECT 'view' as 对象类型,

v.OWNER as 用户,

'' as 对象表空间,

v.VIEW_NAME as 对象名称

FROM dba_views v where v.owner in ('JYC1','JYC2')

union all

SELECT 'procedure' as 对象类型,

p.owner as 用户,

'' as 对象表空间,

DECODE(NVL(p.PROCEDURE_NAME,null),null,p.OBJECT_NAME,p.OBJECT_NAME||'.'||p.PROCEDURE_NAME) as 对象名称

FROM dba_procedures p where p.owner in ('JYC1','JYC2')

union all

SELECT 'trigger' as 对象类型,

tt.owner as 用户, '' as 对象表空间,

tt.trigger_name as 对象名称

FROM dba_triggers tt where tt.owner in ('JYC1','JYC2')) ss

order by ss.用户, ss.对象类型, ss.对象名称;

执行查询脚本

nohup ./o1.sh > o1.log &

查看结果

more o1.txt

相关推荐
book01219 分钟前
MySql数据库运维学习笔记
运维·数据库·mysql
纠结哥_Shrek11 分钟前
Oracle和Mysql的区别
数据库·mysql·oracle
极客先躯12 分钟前
说说高级java每日一道面试题-2025年2月13日-数据库篇-请说说 MySQL 数据库的锁 ?
java·数据库·mysql·数据库的锁·模式分·粒度分·属性分
做梦敲代码13 分钟前
达梦统计信息
数据库·达梦数据库
jiugie1 小时前
MongoDB学习
数据库·python·mongodb
hzulwy1 小时前
MongoDB应用设计调优
数据库·mongodb
我爱松子鱼1 小时前
MySQL 单表访问方法详解
数据库·mysql
我们的五年2 小时前
MySQL存储引擎:选择与应用
数据库·mysql
带娃的IT创业者2 小时前
《Python实战进阶》专栏 No.3:Django 项目结构解析与入门DEMO
数据库·python·django
人间打气筒(Ada)2 小时前
MySQL优化
数据库·mysql