获取命令帮助
exp -helpimp -helpexpdp -helpimpdp -helprman target /?
测试数据准备
CREATE TABLESPACE test01 datafile 'C:\APP\ADMINISTRATOR\ORADATA\TEST\test01.dbf' SIZE 10M autoextend off;CREATE USER hello IDENTIFIED BY world DEFAULT TABLESPACE test01;grant dba to hello;conn hello/world;create table emp01 (id number(3),name varchar2(10));insert into emp01 values(1,'hello01');insert into emp01 values(2,'hello02');insert into emp01 values(3,'hello03');
案例一
1.1、案例说明:在Oracle生产环境中,如何使用exp备份的整个数据库?
1)查看数据库字符集:
select * from nls_database_parameters where parameter='NLS_CHARACTERSET';--或者select userenv('language') from dual;
本机数据库的字符集是:ZHS16GBK,若数据库与环境字符集不一样的话,请先设置字符集,如:
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
2)使用exp备份的整个数据库:
exp system/oracle buffer=65536 feedback=10000 full=y file=exp.dmp log=exp.log


案例二
2.1、案例说明:在Oracle生产环境中,如果某员工删库跑路,把hello整个用户全误删,请使用imp进行恢复。
1)模拟删除hello整个用户:
drop user hello cascade;DROP TABLESPACE test01 INCLUDING CONTENTS AND DATAFILES;


2)先创建表空间,再创建用户授权:
CREATE TABLESPACE test01 datafile 'C:\APP\ADMINISTRATOR\ORADATA\TEST\test01.dbf' SIZE 10M autoextend off;CREATE USER hello IDENTIFIED BY world DEFAULT TABLESPACE test01;grant dba to hello;

3)恢复hello整个用户:
imp system/oracle fromuser=hello touser=hello commit=y buffer=65536 feedback=10000 ignore=y file=exp.dmp log=imp.log


案例三
3.1、案例说明:在Oracle生产环境中,如何使用expdp备份的整个数据库?
1)先建一个备份的文件夹:
cd c:\users\administratormkdir dump

2)创建一个Oralce内部用来识别OS文件系统路径目录并授权:
create directory dump_dir as 'C:\Users\Administrator\dump';grant read,write on directory dump_dir to system;

3)使用expdp备份的整个数据库:
expdp system/oracle directory=dump_dir dumpfile=full_expdp.dmp full=y logfile=expdp.log parallel=2


案例四
4.1、案例说明:在Oracle生产环境中,如果某员工删库跑路,把整个数据库误删,请使用impdp进行恢复。
1)这里就不删数据库了,只模拟删除hello整个用户来搞破坏:
drop user hello cascade;DROP TABLESPACE test01 INCLUDING CONTENTS AND DATAFILES;
2)创建数据库(此处略去),再创建表空间:
CREATE TABLESPACE test01 datafile 'C:\APP\ADMINISTRATOR\ORADATA\TEST\test01.dbf' SIZE 10M autoextend off;
3)配置directory(案例三2)已授权,此步可以省略):
create directory dump_dir as 'C:\Users\Administrator\dump';grant read,write on directory dump_dir to system;
4)使用impdp进行恢复:
impdp system/oracle directory=dump_dir dumpfile=full_expdp.dmp full=y logfile=impdb.log

5)编译无效对象:
@?:@是sqlplus调用脚本的标识,?是指Oracle的安装路径(ORACLE_HOME)。
@?/rdbms/admin/utlrp.sql

6)结果验证:

案例五
5.1、案例说明:在Oracle中,机房需停电维修UPS,请备份整个Oracle环境。
1)停止监听:
lsnrctl stop

2)关闭数据库:
shutdown immediate;

3)创建备份目录:
cd c:\users\administratormkdir backup

4)使用WinRar备份整个Oracle环境:
cd C:\Program Files\WinRAR
Rar a C:\Users\Administrator\backup\oraclebak20201016.rar C:\app
案例六
6.1、案例说明:在Oracle中,机房完成UPS维护后,启动系统,发现Oracle启动失败,数据文件损坏,为了快速恢复业务,你应该怎么处理?
1)删除数据库安装目录(仅为测试,请慎重):
rd /s /q c:\app
2)目录恢复:
cd C:\Program Files\WinRARRar x -o+ C:\Users\Administrator\backup\oraclebak20201016.rar C:\
案例七
7.1、案例说明:在Oracle生产环境中,如何使用rman备份整个数据库?
1)创建备份目录:
cd c:\users\administratormkdir backup1

2)进入rman:
rman target /

3)使用rman备份整个数据库:
CONFIGURE CONTROLFILE AUTOBACKUP ON;run{allocate channel d1 type disk;sql 'alter system archive log current';backup format 'C:\Users\Administrator\backup1\testfull_%U' database include current controlfile plus archivelog;release channel d1;}

案例八
8.1、案例说明:在Oracle生产环境中,如果某员工删库跑路,把Oracle数据目录误删,请使用RMAN进行恢复。
1)模拟把数据文件删除:
关闭数据库:
shutdown immediate;
删除数据文件:
DEL /S /Q C:\app\Administrator\oradata\test\*.*

2)把数据库启动到nomount状态:
startup nomount;

3)进入rman:
rman target /

4)恢复控制文件:
restore controlfile from 'C:\Users\Administrator\backup1\TESTFULL_04VCQ4PG_1_1';

5)将数据库启动到mount状态:
alter database mount;

6)恢复数据库:
restore database;recover database;alter database open resetlogs;
7)结果验证:

原文转载:http://www.shaoqun.com/a/481154.html
走秀网:https://www.ikjzd.com/w/2427
aicpa:https://www.ikjzd.com/w/1373
modcloth:https://www.ikjzd.com/w/1271
获取命令帮助exp-helpimp-helpexpdp-helpimpdp-helprmantarget/?测试数据准备CREATETABLESPACEtest01datafile'C:\APP\ADMINISTRATOR\ORADATA\TEST\test01.dbf'SIZE10Mautoextendoff;CREATEUSERhelloIDENTIFIEDBYworldDEF
tenso:https://www.ikjzd.com/w/1552.html
凹凸曼:https://www.ikjzd.com/w/1392
深圳跨境电商第二春:https://www.ikjzd.com/home/124521
史上出单最快平台Tophatter:注册及运营常见问题详解:https://www.ikjzd.com/home/21297
独立站怎么做? 跨境电商运营品牌独立站的秘籍分享!:https://www.ikjzd.com/home/107612