impdp和expdp注意事项

发布于:2024-05-08 ⋅ 阅读:(26) ⋅ 点赞:(0)

一、新建数据库
1、用户会话字符集,确保源和目标数据库字符集一致
1)查询数据库的字符集
SQL> select userenv('language') from dual;
USERENV('LANGUAGE')
----------------------------------------------------
AMERICAN_AMERICA.AL32UTF8

2)设置Linux操作系统的NLS_LANG环境变量
[oracle@RH207 exp]$export NLS_LANG=AMERICAN_AMERICA.AL32UTF8

2、使用系统视图v$tablespace查询表空间名称:确保源和目标数据库确保表空间一致
查询生产环境表空间名称;
SELECT t.* FROM user_tables t
select username,default_tablespace from dba_users where username='test';

3、导入数据之前先创建同名的表空间,表空间足够大,而且bigfile要成功
创建bigfile表空间的sql语句如下。
CREATE BIGFILE tablespace LOCATION_DATA

logging  

datafile 'E:\app\Administrator\oradata\orcl\LOCATION_DATA.dbf' 

----初始容量10000m
SIZE 10000M 

autoextend on  

--下一次增大为100m, 不限制最大的大小
next 100m maxsize UNLIMITED  

extent management local;

CREATE BIGFILE tablespace TBS_GROUP_MEALS
logging  

datafile '/oracle/app/oradata//TBS_test.dbf' 

----初始容量10000m
SIZE 2000M 

autoextend on  

--下一次增大为100m, 不限制最大的大小
next 100m maxsize UNLIMITED  

extent management local;

4、查看bigfile是否创建成功
SELECT * FROM dba_tablespaces;
例如:SELECT t.BIGFILE,t.* FROM dba_tablespaces t where t.tablespace_name='TBS_test'
确保 t.BIGFILE为ON,才能导入大数据;

5、创建用户,表空间
用户名为new_user
密码为your_password
create or replace directory jy as '/backup/';


CREATE BIGFILE tablespace TBS_GROUP logging 
datafile '/bakeup/TBS_GROUP.dbf' SIZE 1000M autoextend on  next 100m maxsize UNLIMITED extent management local;
create user new_user identified by your_password;
alter user new_user default tablespace TBS_GROUP;
grant connect, resource to new_user;
grant read, write on directory jy to new_user;

6、用户授权
GRANT dba, connect, resource TO new_user;

7、impdp导入数据
export ORACLE_HOME=/oracle/app/oracle/product/11.2.0/db_1
export PATH=$PATH:$ORACLE_HOME/bin

导入某张表的数据
impdp "'/ as sysdba'"  directory=jy dumpfile=expdp_full__20240412_%U.dmp logfile=impdp_$(date +%Y%m%d).log parallel=8  tables=user_tables;

//全量导入

impdp "'/ as sysdba'" directory=jy dumpfile=expdp_full__20240412_%U.dmp logfile=impdp_$(date +%Y%m%d).log full=y parallel=8  table_exists_action=skip  exclude=index exclude=constraint streams_configuration=n;
impdp  "'/ as sysdba


网站公告

今日签到

点亮在社区的每一天
去签到