http://blog.itpub.net/post/43125/523997
关键字: exp imp 导出导入schemaselect sum(bytes) / 1024 / 1024
from dba_segments d
where d.owner = '&username';
exp出的dmp文件大小不会比此处查询出的结果更大。
select d.object_type, count(1)
from dba_objects d
where d.owner = 'ATS001'
group by d.object_type
order by d.object_type;
#df –g
选择一块足够大的空间存放exp出来的dmp文件
根据上面查询的结果可以确定参数filesize和file,exp脚本如下
# vi exp.par
userid='/ as sysdba '
file=exp01.dmp,exp02.dmp
filesize=4000M
owner=username
log=exp.log
direct=y
RESUMABLE=y
RESUMABLE_NAME=exp_myname
RESUMABLE_TIMEOUT=9999999
#exp parfile=exp.par
#df –g
选择一块可以存放dmp文件的路径,将exp出来的dmp文件从源主机传过来。
select *
from v$session v
where v.username = '&username'
and v.STATUS = 'ACTIVE';
通知用户停止session或者手动kill掉
alter system kill session ‘&sid,&serial#’;
密码
select * from dba_users d where d.username=&username;
系统权限授权脚本
select * from dba_sys_privs d where d.grantee='&username';
对象权限授权脚本
select * from dba_tab_privs d where d.grantee='&username';
select * from dba_db_links where owner='&USERNAME';
系统表sys.link$下存有dblink连接用户的密码。
select *
from dba_constraints d
where d.owner <> 'ATS001'
and d.constraint_type = 'R'
and d.r_owner = 'ATS001';
如果存在,则需disable这些FK。
drop user &username cascade;
使用2.2.1的备份脚本重建schema
检查2.3.2创建的schema的密码权限
系统权限
select * from dba_sys_privs d where d.grantee='&username';
对象权限
select * from dba_tab_privs d where d.grantee='&username';
#vi imp.par
userid='/ as sysdba '
file=exp01.dmp
fromuser=username
touser=username
ignore=y
rows=y
log=imp.log
RESUMABLE=y
RESUMABLE_NAME=imp_myname
RESUMABLE_TIMEOUT=9999999
#imp parfile=imp.par
先删除导入的dblink,该dblink很可能是指向生产的。
使用2.2.2的备份脚本重建dblink
获取目标schema所有对象个数,同1.1.2的结果比较
select d.object_type, count(1)
from dba_objects d
where d.owner = 'ATS001'
group by d.object_type
order by d.object_type;
获取失效对象
select *
from dba_objects d
where d.owner = 'ATS001'
and d.status <> 'VALID';
重编译失效对象(以trigger为例)
select 'alter trigger ats001.' || d.object_name || ' compile;'
from dba_objects d
where d.owner = 'ATS001'
and d.status <> 'VALID'
and d.object_type = 'TRIGGER';