一.利用数据泵将数据导出
1.1.确定字符集:
select * from v$nls_parameters;
或
select userenv('language') from dual;
1.2.设置客户端字符集(Windows)
set NLS_LANG = NLS_LANGUAGE_NLS_TERRITORY.NLS_CHARACTERSET
或 linux
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
1.3.确定schema的对象所占用表空间
SQL> Select distinct segment_type,tablespace_name SQL> From dba_segments SQL> Where owner='NC2010';SEGMENT_TYPE TABLESPACE_NAME------------------ ------------------------------TABLE NNC_DATA03TABLE NNC_DATA02LOBSEGMENT NNC_DATA01INDEX NNC_INDEX01INDEX NNC_DATA01INDEX NNC_INDEX02TABLE NNC_DATA01LOBINDEX NNC_DATA01INDEX NNC_INDEX039 rows selected.SQL>
1.4 查看用户默认表空间
select username,default_tablespace from user_users;
1.5.用数据泵导出数据
--创建directory 并赋权SQL> conn / as sysdba;SQL> create directory backup as 'e:\backup';SQL> grant read,write on directory backup to NC60;SQL> select * from dba_directories--导出schema[oracle@localhost ~]$ expdp nc60/nc60 DIRECTORY=backup DUMPFILE=tianlesoftware.dmp SCHEMAS=NC60 logfile=exp.log;--注,如果源库与目的库oracle版本不同,导出时需指定version参数。
二.将dump文件导入RAC或单实例
2.1 确定字符集
select userenv('language') from dual;
2.2 设置客户端字符集(linux)
export NLS_LANG = NLS_LANGUAGE_NLS_TERRITORY.NLS_CHARACTERSET
2.3 检查RAC运行状态
2.4 创建相关用户和表空间
--查看数据文件select file_name from dba_data_files;--创建表空间(与1.3查询结果相同)--SQL> create tablespace NNC_DATA01 datafile '+DATA/orcl/datafile/tianlesoftware.dbf' size 50m;--SQL> create tablespace NNC_DATA02 datafile '+DATA/orcl/datafile/tianlesoftware.dbf' size 50m;--SQL> create tablespace NNC_DATA03 datafile '+DATA/orcl/datafile/tianlesoftware.dbf' size 50m;--SQL> create tablespace NNC_INDEX01 datafile '+DATA/orcl/datafile/tianlesoftware.dbf' size 50m;--SQL> create tablespace NNC_INDEX02 datafile '+DATA/orcl/datafile/tianlesoftware.dbf' size 50m;--SQL> create tablespace NNC_INDEX03 datafile '+DATA/orcl/datafile/tianlesoftware.dbf' size 50m;--创建用户SQL> create user NC60 identified by NC60 default tablespace NNC_DATA01 temporary tablespace temp;--赋予权限Grant resource,connect,dba to NC60;
2.5 创建导入directory
SQL> create directory backup as '/backup';
SQL> Grant read,write on directory backup to NC60;
2.6 导入数据
[oracle@rac1 u01]$ export ORACLE_SID=orcl1
[oracle@rac1 u01]$ impdp nc60/nc60 DIRECTORY=BACKUP DUMPFILE=NC60.dmp SCHEMAS=NC60 logfile=impdp.log;
注,如果源库与目的库oracle版本不同,导入时需指定version参数。