selectcount(*) from dba_objects where owner in ('CEDE001','ABCDEFG01'); selectcount(object_type),object_type from dba_objects where owner in ('CEDE001','ABCDEFG01') groupby object_type; select owner,object_type,count(*) from dba_objects where owner in ('CEDE001','ABCDEFG01') groupby owner,object_type orderby1,2;
检查数据库组件
1 2
col comp_name for a60 select comp_name,version, status from dba_registry;
检查表空间
目标库和源库都执行,进行比较
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
SELECT a.TABLESPACE_NAME "TableSpace Name", round(a.BYTES/1024/1024) "Total MB", round((a.BYTES-nvl(b.BYTES, 0)) /1024/1024) "Used MB ", nvl(round(b.BYTES/1024/1024), 0) "Free MB ", round((1-((a.BYTES-nvl(b.BYTES,0))/a.BYTES))*100,2) "Pct Free", a.AUTO FROM (SELECT TABLESPACE_NAME, sum(BYTES) BYTES, max(AUTOEXTENSIBLE) AUTO FROM sys.dba_data_files GROUPBY TABLESPACE_NAME) a, (SELECT TABLESPACE_NAME, sum(BYTES) BYTES FROM sys.dba_free_space GROUPBY TABLESPACE_NAME) b WHERE a.TABLESPACE_NAME = b.TABLESPACE_NAME (+) ORDERBY ((a.BYTES-b.BYTES)/a.BYTES) DESC;
SQL>selectdistinct(tablespace_name) from dba_segments where owner ='CEDE001'or owner='ABCDEFG01'; TABLESPACE_NAME ------------------------------ ABCDEFG01DATA ABCDEFG01INDX
检查directory
1 2 3 4 5 6 7 8
col directory_name for a25 col DIRECTORY_PATH for a60 col owner for a15 select owner,directory_name,directory_path from dba_directories;
SELECT DBMS_LOB.substr(DBMS_METADATA.get_ddl('DIRECTORY',DIR.directory_name),4000,1) FROM DBA_DIRECTORIES DIR WHERE directory_name NOTin('DATA_PUMP_DIR','ORACLE_OCM_CONFIG_DIR');
检查dblink
1 2 3 4 5 6 7 8 9 10
col db_link for a30 col username for a20 col host for a30 select*from dba_db_links where owner='PUBLIC';
col owner format a15; col db_link format a20; col host format a20; set heading on select*from dba_db_links;
如存在db_link,确保准备好创建脚本
1 2
select DBMS_LOB.substr(DBMS_METADATA.GET_DDL('DB_LINK',dl.db_link,dl.owner),4000,1) FROM DBA_DB_LINKS dl;) select DBMS_LOB.substr(DBMS_METADATA.get_ddl('DB_LINK',DL.DB_LINK,'PUBLIC'),4000,1) from dba_db_links DL where owner='PUBLIC';
检查同义词
1
SELECT*FROM dba_synonyms WHERE table_owner in ('ABCDEFG01','CEDE001');
如存在,准备生成同义词脚本
1
SELECT'CREATE PUBLIC SYNONYM '|| synonym_name||' FOR '|| table_owner||'.'|| table_name||';' ROM dba_synonyms WHERE table_owner in ('ABCDEFG01','CEDE001');
检查job
1 2 3 4 5
col schema_user for a12 col intervalfor a30 col what for a60 select job,what,schema_user,intervalfrom dba_jobs orderby what; select owner,job_name from dba_scheduler_jobs;
查看角色 RESOURCE 权限
1
select Privilege from ROLE_SYS_PRIVS where ROLE=upper('RESOURCE');
selectcount(*) from dba_objects where owner in ('CEDE001','ABCDEFG01'); selectcount(object_type),object_type from dba_objects where owner in ('CEDE001','ABCDEFG01') groupby object_type; select owner,object_type,count(*) from dba_objects where owner in ('CEDE001','ABCDEFG01') groupby owner,object_type orderby1,2;
编译失效对象
1
exec utl_recomp.recomp_parallel(8);
统计信息收集
1 2 3 4 5 6 7
vi gtd.sh sqlplus /as sysdba<<_EOF exec DBMS_STATS.GATHER_FIXED_OBJECTS_STATS(); dbms_stats.gather_schema_stats(ownname=>'CEDE001',cascade=>TRUE,degree=>4,estimate_percent=>10); exec dbms_stats.gather_schema_stats(ownname=>'ABCDEFG01',cascade=>TRUE,degree=>4,estimate_percent=>10); _EOF nohup sh gtd.sh &