1.先从服务器中EXPDP,为了防止数据文件过大,只取用户下每张表的前100条记录:
--先导出表数据的前100条记录:
expdp tr_user/tr_user dumpfile=daochu.dmp include=table query="'where rownum<=100'";
--再导出视图、过程、函数、类型、序列等:
expdp tr_user/tr_user dumpfile=daochu2.dmp include=view,procedure,function,type,sequence
2.往目标数据库中导入,首先创建同样用户:
sqlplus / as sysdba
create user tr_user
identified by tr_user;
3.赋权:
grant
create session, create any table, create any view ,create any index, create any procedure,
alter any table, alter any procedure,
drop any table, drop any view, drop any index, drop any procedure,
select any table, insert any table, update any table, delete any table
to tr_user;
grant dba to tr_user;
4.建立directory:
sqlplus / as sysdba
create directory TJ AS 'd:\TJ';
5.赋予对目录的读写权限:
grant read on directory TJ to system;
grant write on directory TJ to system;
6.在新库中建立相应的表空间:
select name from v$tempfile;--通过此SQL查看表空间所在路径
--建立临时表空间
create temporary tablespace user_temp
tempfile '/home/oracle/test1/user_temp.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;
--建立数据表空间
create tablespace user_data
logging
datafile '/home/oracle/test1/user_data.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;
7.进行impdp:
impdp tr_user/tr_user schemas=tr_user directory=TJ dumpfile =daochu.dmp exclude=index,constraint;--其中参数schemas是确定用户名的,有可能如果加这个参数可以直接IMPDP不用建立对应的用户,因为IMPDP是不能默认是不能导入索引和主外键的,参数exclude是确定导入的同时吧索引以及主外键一起导入。
impdp tr_user/tr_user directory=TJ dumpfile =daochu2.dmp;--导入视图、过程、函数、类型、序列。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28542746/viewspace-775911/
,如需转载,请注明出处,否则将追究法律责任。