Oracle备份还原数据库

备份数据库:
打开cmd命令窗口,输入以下命令(根据自己需要修改相应的账户密码以及路径):    

导出: exp user/[email protected]/orcl  file=d:\oracle.dmp LOG=d:\oracle.LOG  full=y indexes=n statistics=none

备注:user是指备份时,登录数据库实例orcl 的用户名;
password是用户user登录数据库orcl 时的密码;
orcl 是Oracle数据库的实例名。
file=d:\oracle.dmp  是指备份文件的存放路径。

LOG=d:\oracle.LOG 是指日志的输出地址。
full=y是将用户user在orcl 数据库实例中的所有文件都备份,也就是完整备份
导入: imp local_kettle/[email protected]/orcl  file=D:\KETTLE.dmp full=y ignore=y statistics=none  


还原数据库:

1.创建表空间:
create tablespace IDX_INDB logging datafile 'D:\app\tablespace\IDX_INDB01.dbf' size 10240M reuse autoextend on next 100M maxsize unlimited ;
create tablespace DATA_INDB logging datafile 'D:\app\tablespace\DATA_INDB01.dbf' size 10240M reuse autoextend on next 100M maxsize unlimited ;

create tablespace IDX_MKDB logging datafile 'D:\app\tablespace\IDX_MKDB01.dbf' size 10240M reuse autoextend on next 100M maxsize unlimited ;
create tablespace DATA_MKDB logging datafile 'D:\app\tablespace\DATA_MKDB01.dbf' size 10240M reuse autoextend on next 100M maxsize unlimited ;

create tablespace KETTLE logging datafile 'D:\app\tablespace\KETTLE.dbf' size 20M reuse autoextend on next 50M maxsize unlimited ;

CREATE TABLESPACE INDBADMIN         
         DATAFILE 'D:\jgbs\initdb\db1.dbf'
         SIZE 500M
         AUTOEXTEND ON
         NEXT 100M MAXSIZE UNLIMITED
         EXTENT MANAGEMENT LOCAL;
ALTER TABLESPACE INDBADMIN  ADD DATAFILE   'D:\jgbs\initdb\db2.dbf'  
SIZE 500M
AUTOEXTEND  ON NEXT 100M maxsize unlimited ;


2.创建用户
CREATE USER INDBADMIN IDENTIFIED BY INDBADMIN
         ACCOUNT UNLOCK
         DEFAULT TABLESPACE INDBADMIN;
GRANT CONNECT, RESOURCE,dba TO INDBADMIN;

CREATE USER KETTLE IDENTIFIED BY KETTLE
         ACCOUNT UNLOCK
         DEFAULT TABLESPACE INDBADMIN;
GRANT CONNECT, RESOURCE,dba TO KETTLE;

CREATE USER MK_DB IDENTIFIED BY MK_DB
         ACCOUNT UNLOCK
         DEFAULT TABLESPACE INDBADMIN;
GRANT CONNECT, RESOURCE,dba TO MK_DB;

3.导入dmp文件
    imp INDBADMIN/[email protected]/orcl  file=D:\app\database\INDBADMIN.dmp full=y ignore=y statistics=none
    imp KETTLE/[email protected]/orcl  file=D:\app\database\kettle.dmp full=y ignore=y statistics=none
    imp MK_DB/[email protected]/orcl  file=D:\app\database\mk_db.dmp full=y ignore=y statistics=none

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