【数据库】导入dmp文件的自用脚本整理

dmp文件导入到不同表空间不同用户名下

总有些时候要自己动手,存个脚本,以备不时之需。

(1)directory

-- 查询
select * from dba_directories;
-- 新建或者替换
create or replace directory dump_dir as '/dumpfile/tempfile';
--添加权限
grant read,write on directory dump_dir to user1;
--删除
drop directory dump_dir;

(2)tablespace

--新建
create tablespace 表空间名 logging datafile '/存储路径/存储文件.dbf' 
size 128m 
autoextend on 
next 100m maxsize 10000m 
extent management local;
--创建用户名和密码
create user 用户名 identified by 密码 DEFAULT TABLESPACE 表空间;
--添加权限
grant create session, create any table, create any view , create any index, create any sequence, create any procedure to 表空间名;
grant alter any table, alter any sequence, alter any procedure to 表空间名;
grant drop any table, drop any sequence, drop any view, drop any index, drop any procedure to 表空间名;
grant select any table, insert any table, update any table, delete any table to 表空间名;
grant unlimited tablespace to 表空间名;
grant imp_full_database to 表空间名;
grant sysdba to 表空间名;

(3)导入

impdp \
用户名/密码@192.168.1.2:1521/orcl \
directory=步骤1创建的directory \
dumpfile=导入的dmp文件.dmp \
logfile=日志.log \
remap_schema=原schema:本次导入的schema \
remap_tablespace=原tablespace:本次导入的schema \
table_exists_action=replace;

(4)删除

---查找用户
select * from dba_users;
--删除非空表空间及其物理文件
drop tablespace 表空间名 including contents and datafiles;
--删除用户名
drop user 用户名 cascade;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值