Oracle导入(impdp)比较大的数据,包括创建表空间、创建用户、导入数据等;含expdp及其它
作者:互联网
一、以 sys管理员身份登录sqlplus,打开命令行(cmd.exe),语法:
sqlplus sys/Manager001 as sysdba
二、创建独立的表空间
create tablespace USER_TEST_DATA logging datafile 'C:\app\Andy\oradata\orcl\usertestdata.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local; create temporary tablespace USER_TEST_TEMP tempfile 'C:\app\Andy\oradata\orcl\usertesttemp.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local;
对应地,删除表空间命令为:
drop tablespace USER_TEST_DATA including contents and datafiles; drop tablespace USER_TEST_TEMP including contents and datafiles;
三、创建用户,并赋予相应权限
create user MYTEST identified by "test001" default tablespace USER_TEST_DATA temporary tablespace USER_TEST_TEMP; grant connect to mytest; grant resource to mytest; grant dba to mytest; grant exp_full_database to mytest; grant imp_full_database to mytest;
对应地,删除用户命令为:
drop user MYTEST cascade;
四、创建DUMP目录(导出的数据文件所在目录),并赋予权限刚刚创建的用户
create directory DUMP_DIR as 'G:\other\dpdump'; grant read,write on directory DUMP_DIR to MYTEST;
对应地,删除DUMP目录命令为:
drop directory DUMP_DIR
注意:此处的DUMP_DIR目录必须存在,否则在后面impdp环节会出错!
五、导入数据
本例中,导出文件已经加密,有口令。步骤:退出sqlplus,然后在cmd窗口,执行如下命令:
impdp mytest/test001@orcl DIRECTORY=DUMP_DIR DUMPFILE=mytest_fc.dmp ENCRYPTION_PASSWORD=Manager001 schemas=MYTEST
六、导出文件命令参考:
expdp mytest/test001@orcl DIRECTORY=DUMP_DIR DUMPFILE=mytest_fc.dmp ENCRYPTION=ALL ENCRYPTION_MODE=PASSWORD ENCRYPTION_PASSWORD=Manager001 SCHEMAS=MYTEST
七、附加几条命令,供参考
1. 删除当前用户下所有表
select 'drop table '||TABLE_NAME||' cascade constraints purge;' from user_tables; select 'drop sequence '||SEQUENCE_NAME||';' from user_sequences;
先在SQL Developer中执行上述命令,将结果再粘贴执行即可。
2. 缩减表空间
alter database datafile 'C:\app\Andy\oradata\orcl\USERTESTDATA.DBF' resize 50M; alter tablespace USER_TEST_TEMP shrink space keep 20M; -- 11G支持
标签:impdp,DUMP,mytest,创建,drop,导入,tablespace,USER,TEST 来源: https://www.cnblogs.com/nayitian/p/15027163.html