• 欢迎访问少将全栈,学会感恩,乐于付出,珍惜缘份,成就彼此、推荐使用最新版火狐浏览器和Chrome浏览器访问本网站。
  • 吐槽,投稿,删稿,交个朋友,商务沟通v:ai_draw
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏少将全栈吧

Oracle 把一个用户的数据导入另一个用户

点滴 admin 8年前 (2016-08-31) 2368次浏览 已收录 0个评论 扫描二维码

1. 导出数据

[exp版本]
exp user/password file=d:temp.dmp owner=user consistent=y direct=y

[expdp版本]
使用expdp之前,需要现在Oracle里面建directory
create directory dump as ’/u01/dump’;
授予用户对directory的read/write权限
grant read,write on directory  dump to [username];
用户需要resource或者dba的权限,才能expdp
grant resource to [username] ;


expdp user/password dumpfile=temp.dmp directory=dump


2。导入之前,清空目标用户所有的对象
最简单的办法,把目标用户删了再重建
drop   user   newuser   cascade; 
再创建用户


//创建临时表空间
create temporary tablespace [TempTableSpaceName] tempfile ’Filename.dbf’ size 32m autoextend on next 32m maxsize 2048mextent management local;
//创建数据表空间
create tablespace [TableSpaceName] logging datafile ’Filename.dbf’ size 32m autoextend on next 32m maxsize 2048mextent management local;
//创建用户
create user [username] identified by [password] default tablespace users temporary tablespace temp;
//授予权限
grant connect,dba to [username] ;

3。导入数据

[imp版本]
imp newuser/password file=temp.dmp ignore=y fromuser=olduser touser=newuser


[impdp版本]
同样,使用impdp之前,需要现在Oracle里面建directory
create directory dump as ’/u01/dump’;
授予用户对directory的read/write权限
grant read,write on directory  dump to [username];
授予用户dba权限
grant dba to [username] ;


impdp user/password dumpfile=temp.dmp directory=dump remap_tablespace=[old_table_space]:[new_table_space] table_exists_action=replace;



//导入数据后取消DBA权限
revoke dba from [username];


//List directories
SELECT * FROM dba_directories;

喜欢 (0)
[🍬谢谢你请我吃糖果🍬🍬~]
分享 (0)
关于作者:
少将,关注Web全栈开发、项目管理,持续不断的学习、努力成为一个更棒的开发,做最好的自己,让世界因你不同。
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址