今天给大家分享oracle 数据泵迁移笔记,废话不多说代码如下!
统计数据文件大小
rman target /
report schema;
exit
统计数据库用户
select USERNAME,USER_ID,CREATED from dba_users order by 2 desc;
统计数据量
Select sum(bytes) from dba_segments;
查看数据库字符集及国家字符集
select value from v$nls_parameters where parameter='NLS_CHARACTERSET';
select value from v$nls_parameters where parameter='NLS_NCHAR_CHARACTERSET';
查询哪些表空间含XMLTypes:
注:自Oracle 10gR2开始,可以传输含XMLTypes的表空间,不过必须使用IMP/EXP而不能选择数据泵(IMPDP/EXPDP),并确保IMP/EXP命令的CONSTRAINTS和TRIGGERS参数设置为Y。
select distinct p.tablespace_name from dba_tablespaces p, dba_xml_tables x, dba_users u, all_all_tables t where t.table_name = x.table_name and t.tablespace_name = p.tablespace_name and x.owner = u.username;
统计表空间大小及空闲
select f.tablespace_name,a.total,f.free,round((f.free/a.total)*100) "% Free" from (select tablespace_name,sum(bytes/(1024*1024)) total from dba_data_files group by tablespace_name) a,(select tablespace_name,round(sum(bytes/(1024*1024))) free from dba_free_space group by tablespace_name) f where a.tablespace_name=f.tablespace_name(+) order by "% Free";
查看无效对象
select count(*) from all_objects where owner in ('SCHEMA1','SCHEMA2',...) and status='INVALID';
---执行处理无效对象的脚本
@?/rdbms/admin/utlrp
select count(*) from all_objects where owner in ('SCHEMA1','SCHEMA2',...) and status='INVALID';
查看DBLINK
select owner,object_name,object_type from dba_objects where object_type='DATABASE LINK';
注:当前用户的DBLINK不支持用于数据泵导出或导入,其他DBLINK正常
8.查看DBMS_JOB产生的JOB(DBMS_SCHEDULER创建的JOB强制导出或导入)
select count(*) from dba_jobs where schema_user in ('SCHEMA1','SCHEMA2',...);
注:
-dba_jobs
不包括export/import产生的job
由DBMS_JOB创建
受exclude、include参数限制导出导入
-dba_scheduler_jobs(替代dba_jobs)
由DBMS_SCHEDULER.CREATE_JOB创建
不受exclude、include参数限制,强制导出导入
-bug:按schema导出时,由dbms_job生成的job不导出,由dbms_scheduler生成的正常导出
--全库导出正常
--在11.2, 10.2.0.5, 11.1.0.7中修复
待迁移对象的总数
select count(*) from all_objects where owner in ('SCHEMA1','SCHEMA2',...);
待迁移对象的类型
select object_type,count(1) as "NUM" from all_objects where owner in ('SCHEMA1','SCHEMA2',...) group by object_type;
创建数据泵目录
select * from dba_directories;
create directory dpdir as '/tmp/dpdir';
*导出前,注意system表空间和归档存放空间,推荐system表空间至少20GB剩余,关闭归档日志
导出数据
$ expdp \"/ as sysdba\" DIRECTORY=dpdir DUMPFILE=jzzf%U.dmp logfile=jzzf_expdp.log filesize=3G cluster=N exclude=STATISTICS schemas=SCHEMA1,SCHEMA2,...
其他:
---查看数据泵job
select * from dba_datapump_jobs;
---查看exclude参数可以排除的对象
col object_path for a70
col comments for a70
select object_path from database_export_objects
如果觉得对您有帮助的话,请小编喝杯咖啡吧~~~