oracle数据库还原步骤

RMAN> list archivelog all;
gwamqa
drop user gwamqa cascade;
alter user system identified by Abc12345;
alter user gwamqa identified by Abc12345;

drop tablespace GWAM_Test_temptablespace including contents and datafiles cascade constraint;
drop tablespace GWTS01 including contents and datafiles cascade constraint;
------------------------------------------ 恢复DB -----------------------
1.  创建数据库实例  GWAMRTHB
创建成功之后,启动sqlplus(如下):
sqlplus
system/Abc12345@GWAMRTHB   (假设system的密码为Abc12345  )

2.创建表空间
   表空间名为GWTS01
  create tablespace GWTS01
  datafile 'D:\大气预警\DataBase\GWTS01.dbf' size 500M
  AUTOEXTEND ON NEXT 20M
  extent management local autoallocate;

3. 创建临时表空间GWAM_Test_temptablespace
create temporary tablespace GWAM_Test_temptablespace
tempfile 'D:\大气预警\DataBase\GWAM_temp.dbf' 
size 50m  
autoextend on  
next 10m maxsize 20480m  
extent management local;

4.创建用户
create user gwamqa identified by Abc12345
  default tablespace GWTS01
  temporary tablespace GWAM_Test_temptablespace;
 
5. 
alter tablespace GWTS01  add datafile 'D:\大气预警\DataBase\GWTS02.dbf'size 500M AUTOEXTEND ON NEXT 20M;
alter tablespace GWTS01  add datafile 'D:\大气预警\DataBase\GWTS03.dbf'size 500M AUTOEXTEND ON NEXT 20M;
alter tablespace GWTS01  add datafile 'D:\大气预警\DataBase\GWTS04.dbf'size 500M AUTOEXTEND ON NEXT 20M;
alter tablespace GWTS01  add datafile 'D:\大气预警\DataBase\GWTS05.dbf'size 500M AUTOEXTEND ON NEXT 20M;
alter tablespace GWTS01  add datafile 'D:\大气预警\DataBase\GWTS06.dbf'size 500M AUTOEXTEND ON NEXT 20M;
alter tablespace GWTS01  add datafile 'D:\大气预警\DataBase\GWTS07.dbf'size 500M AUTOEXTEND ON NEXT 20M;

6.给用户分配权限
grant connect,resource,dba to gwamqa;
grant exp_full_database to gwamqa;
grant imp_full_database to gwamqa;
grant dba to gwamqa;
退出sqlplus

7.恢复数据库 (注意:下面的语句有时会被自动截断,在执行前务必检查下)
在DOS界面下:
imp system/Abc12345@GWAMRTHB fromuser=gwamqa touser=gwamqa file=H:\20180614db\20181121db.dmp ignore=y  buffer=10000000 STATISTICS=NONE constraints =n;'
impdp system/Abc12345 DIRECTORY=ora_dir DUMPFILE=GWAM2018121301.DMP table_exists_action=replace REMAP_SCHEMA=gwamqa:gwamqa;
imp system/Abc12345@GWAMRTHB fromuser=gwamqa touser=gwamqa tables=(gwm_fact_alarms_2018) file=H:\20180614db\gwamqa2018103001.dmp ignore=y  buffer=10000000 STATISTICS=NONE constraints =n;'
exp system/Abc12345@GWAMRTHB file=H:\20180902db.dmp owner=(gwamqa);
exp gwamqa/Abc12345@GWAMRTHB file=H:\GWAM2018122101.dmp tables=(gw_if_tempstation);
expdp system/Abc12345@GWAMRTHB schemas=gwamqa dumpfile=GWAM2018122501.dmp DIRECTORY=ora_dir tables=(emp,dept)

expdp system/Abc12345@GWAMRTHB schemas=gwamqa dumpfile=GWAM20190102.dmp DIRECTORY=ora_dir

create directory ora_dir as 'd:\ora_dir';
grant read,write on directory ora_dir to system;


8. 删掉DBMS_Jobs中的所有job  (这非常关键) 

你可能感兴趣的:(数据库)