常见的实现方式:
rman
exp/imp expdp/impdp
DG
OGG
主要是看停机时间了,方法很多,数据量小,就导出,如果时间要求很高,那可以采取dg或ogg或类似的技术。减低downtime。
如果时间充足,保险的方式还是通过rman恢复,你可以进行rman增量,追加archivelog去恢复,也能最大程度降低停机时间。
sqlplus /nolog
conn 用户名/密码@服务器ip/orcl:1521
查看单实例数据库版本:SQL> select * from v$version;BANNER--------------------------------------------------------------------------------Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionPL/SQL Release 11.2.0.1.0 - ProductionCORE 11.2.0.1.0 ProductionTNS for 64-bit Windows: Version 11.2.0.1.0 - ProductionNLSRTL Version 11.2.0.1.0 - Production
查看我们常规将用户表空间放置的位置:执行如下sql:
select name from v$datafile;
查看表空间信息:
TABLESPACE_NAME CURRENT_TOTAL(MB) USED(MB) FREE(MB) FREE% AUTOEXT MAX_TOTAL(MB)------------------------------ ----------------- ---------- ---------- ---------- ------- -------------SYSTEM 760 752.31 7.6875 1.01 YES 32767.98SYSAUX 730 674.56 55.4375 7.59 YES 32767.98EXAMPLE 198.13 177.56 20.5625 10.38 YES 32767.98USERS 5 4.13 .875 17.5 YES 32767.98TBS_XXX 1524 177.56 1346.4375 88.35 NO 1524UNDOTBS1 760 41.19 718.8125 94.58 YES 32767.98TBS_XXX 500 1.75 498.25 99.65 NO 5007 rows selected.
查看单实例数据库字符集:
select * from v$nls_parameters where parameter='NLS_CHARACTERSET';或者:SQL> select userenv('LANGUAGE') from dual;USERENV('LANGUAGE')----------------------------------------------------SIMPLIFIED CHINESE_CHINA.ZHS16GBK
查看服务器本地客户端的字符集:
C:\Users\Administrator>echo %NLS_LANG%%NLS_LANG%设置当前客户端窗口的字符集: 一般要和数据库的字符集一致!!!
C:\Users\Administrator>set NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBKC:\Users\Administrator>echo %NLS_LANG%SIMPLIFIED CHINESE_CHINA.ZHS16GBK
Windows: set NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
Linux: export NLS_LANG=SIMPLIFIEDCHINESE_CHINA.ZHS16GBK 查看目标数据库RAC的字符集:
查看数据库DBID:
SQL> select dbid from v$database;DBID----------1465955268
SELECT * FROM TRANSPORT_SET_VIOLATIONS;
创建导出目录:使用数据泵之前,需要创建一个存放文件的目录。 这个目录要写入oracle的数据字典中才能识别。(1)先查看一下已经存在的目录:SQL> col owner format a5SQL> col directory_name format a25SQL> col DIRECTORY_PATH format a100SQL> select * from dba_directories;OWNER DIRECTORY_NAME DIRECTORY_PATH----- ------------------------- ----------------------------------------------------------------------------------------------------SYS SUBDIR D:\app\Administrator\product\11.2.0\dbhome_1\demo\schema\order_entry\/2002/SepSYS SS_OE_XMLDIR D:\app\Administrator\product\11.2.0\dbhome_1\demo\schema\order_entry\SYS LOG_FILE_DIR D:\app\Administrator\product\11.2.0\dbhome_1\demo\schema\log\SYS DATA_FILE_DIR D:\app\Administrator\product\11.2.0\dbhome_1\demo\schema\sales_history\SYS XMLDIR c:\ade\aime_dadvfh0169\oracle/rdbms/xmlSYS MEDIA_DIR D:\app\Administrator\product\11.2.0\dbhome_1\demo\schema\product_media\SYS DATA_PUMP_DIR D:\app\Administrator/admin/orcl/dpdump/SYS ORACLE_OCM_CONFIG_DIR D:\app\Administrator\product\11.2.0\dbhome_1/ccr/state
数据库层面创建目录
Linux下格式:create directory exp_dir as '/home/oracle/exp';windows环境格式:(可参考上述已经存在的目录文件路径)
create directory exp_dir as 'D:\app\Administrator/admin/orcl/dpdump/exp';将上述创建的目录:DATA_PUMP_DIR 赋给你需要进行导出操作的用户,如果用管理员用户操作,这步可以略过:
grant read,write on directory exp_dir to test1;磁盘本地创建相关目录:
Linux环境:mkdir /home/oracle/exp --跟上方数据库层面创建的目录一致windows环境:到指定的目录 新建文件夹就行+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
SQL> select username from dba_users;SQL> select table_name from dba_tables where owner='指定用户';
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
执行导出命令:
expdp 用户名/密码 DIRECTORY=DATA_PUMP_DIR DUMPFILE = %u_0612.dmp LOGFILE = %u_exp.log SCHEMAS = 用户 parallel=2;