本文共 3615 字,大约阅读时间需要 12 分钟。
oracle import & export 操作相关脚本
select osuser, username, sid, serial#, sql_text from v$session a, v$sqltext b where a.sql_address = b.address select tablespace_name, round(sum(bytes)/1024/1024) sum_mbytes (select distinct tablespace_name where owner in ('SSO', 'SSOWEB') select tablespace_name, round(sum(bytes)/(1024*1024)) as free_space round(a.bytes/1024/1024) total, round(b.bytes/1024/1024) used, round(c.bytes/1024/1024) free, round((b.bytes*100)/a.bytes) "% used", round((c.bytes*100)/a.bytes) "% free" from sys.sm$ts_avail a,sys.sm$ts_used b,sys.sm$ts_free c where a.tablespace_name=b.tablespace_name and a.tablespace_name=c.tablespace_name select 'create tablespace ' || tablespace_name || ' datafile ' || '''' || file_name ||'''' || ' size ' || round(bytes/1024/1024) || 'm' (select distinct tablespace_name where owner in ('SSO', 'SSOWEB') set heading on
6)在产品库执行 3.验证 IMPORT 操作的结果是否正确的步骤,并记录下每条命令的结果,以便跟导入后在测试库执行的相同命令的结果进行对比。 select * from dba_directories; create directory pump_dir as '/opt/oracle/backup/pump'; grant read, write on directory pump_dir to <username>; select * from user_role_privs; dumpfile=pp_$(date +%y%m%d).dmp job_name=job_sso_exp$(date +%y%m%d) dumpfile=pp_$(date +%y%m%d).dmp TABLE_EXISTS_ACTION=REPLACE job_name=job_sso_imp$(date +%y%m%d) b.导入后,在测试库执行下列语句,并跟在 1.export 前的准备工作 select owner, object_type, count(*) where owner in ('MAIN', 'SSO', 'SSOWEB', 'USD') group by owner, object_type order by owner, object_type select owner, sum(num_rows) sum_rows where owner in ('SSO', 'SSOWEB', 'MAIN', 'USD') where owner in ('SSO', 'SSOWEB', 'MAIN', 'USD') order by owner, num_rows desc select owner, sum(num_rows) sum_rows where owner in ('SSO', 'SSOWEB', 'MAIN', 'USD') where owner in ('SSO', 'SSOWEB', 'MAIN', 'USD') and num_rows > 1000000 select object_type, object_name, status where owner in ('SSO', 'MAIN') and status = 'INVALID' select owner, index_name, table_name, status where status <> 'VALID' and owner in ('MAIN', 'SSO', 'USD') select index_owner, index_name, partition_name, tablespace_name, status and owner in ('MAIN', 'SSO', 'SSOWEB')) select 'alter index ' || owner || '.' || index_name || ' rebuild;' where status = 'INVALID' and owner in ('SCOTT') 注:本操作因不关心存储过程,所以没有相应的重编译存储过程的语句。 本文转自zkjian517 51CTO博客,原文链接: http://blog.51cto.com/zoukejian/56433 转载地址:http://doqbx.baihongyu.com/