Oracle備份與恢復指令碼

2021-08-27 07:45:05 字數 1789 閱讀 9842

@echo off

set oracle_username=youroracle_username

set oracle_password=your_password

set local_tnsname=local_tnsname

set url=%oracle_username%/%oracle_password%

if not %local_tnsname% == "" set url=%url%@%local_tnsname%

rem 執行時請確保同一目錄下無重名的檔案

exp %url% file=%oracle_username%.dmp log=%oracle_username%.log

將上述指令碼儲存為乙個bat檔案執行即可。指令碼將local_tnsname指定的資料庫中使用者youroracle_username的所有內容匯出到youroracle_username.dmp檔案中,日誌寫到youroracle_username.log中。

2.1 建立使用者

第一步,把使用者youroracle_username(如果原來有此使用者的話)徹底刪除

drop user youroracle_username cascade
第二步,建立表空間,根據需要設定your_tablespace,size和maxsize等。

create tablespace your_tablespace

logging

datafile 'd:\oracle\product\10.2.0\oradata\your_tablespace.dbf'

size 512m

autoextend on

next 64m maxsize 1024m

extent management local;

第三步,建立該使用者

create user youroracle_username

identified by your_password

default tablespace your_tablespace

temporary tablespace temp

第四步,賦予許可權

grant dba to youroracle_username with admin option
2.2 用imp恢復

命令列下執行此指令碼

imp youroracle_username/your_password@local_tnsname file=youroracle_username.dmp log=youroracle_username.log full=y
使用windows批處理呼叫sqlplus執行sql語句:

@echo off

rem sqlplus username/password@service @mysql.sql

sqlplus youroracle_username/your_password@local_tnsname @20121228.sql

exit

其中20121228.sql是需要執行的sql指令碼。

注:文中youroracle_username,your_password以及local_tnsname需要使用時根據實際情況替換為特定的字串。

Oracle備份與恢復

oracle的備份與恢復有三種標準的模式,大致分為兩大類,備份恢復 物理上的 以及匯入匯出 邏輯上的 而備份恢復又可以根據資料庫的工作模式分為非歸檔模式 nonarchivelog style 和歸檔模式 archivelog style 通常,我們把非歸檔模式稱為冷備份,而相應的把歸檔模式稱為熱備...

oracle備份與恢復

完全恢復 前提條件 所需要的歸檔日誌檔案和online redolog都在 方式一 資料庫在開啟的情況下進行恢復 適合的環境 普通資料檔案損壞 非system undo的表空間的資料檔案 環境準備 1 以scott使用者登入,往test表當中插入資料,並導致日誌切換至少3組以上。sql select...

oracle 備份與恢復

oracle備份和恢復 1 邏輯備份 不用去拷貝資料庫的物理檔案 備份邏輯上的結構 外部的工具 匯出和匯入的工具 dos下的命令 cmd下執行 匯出exp export縮寫形式 檢視幫助 exp help y 使用引數檔案匯出 exp parfile c abc.par abc.par的內容 a s...