標籤:
1、首先,解釋幾個詞語
directory:一般建立directory都是為了用資料泵匯入/匯出資料用,其實directory還有很多別的用處,本文不做闡述
schemas: 你用“使用者 user”來理解就很容易了,每個模式(user)下可以有一套互不干擾的對象。你如果想要訪問其他模式的對象,
需要指定schema的name,實際就是指定username。 如,你要訪問模式scott的表emp,而你所在的模式(使用者)是tiger,
那你要這樣寫: select * from scott.emp;
2、備份資料庫語句:
模型:expdp 使用者名稱/密碼@服務名(或者sid名)
expdp user/[email protected] dumpfile=database.dmp directory=w_dir schemas=system;
一般情況下,在使用expdp工具備份資料庫的時候,一般需要使用DIRECTORY參數指定備份檔案和記錄檔的存放位置。其實DIRECTORY參數
並不是必須的。我們可以將目錄寫到dumpfile參數和logfile參數中以便實現同樣的目的。
建立directory
create directory w_dir as ‘d:\dumpfile‘;
在電腦D盤下建立一個叫dumpfile的檔案夾,用來存放備份檔案,以及還原的時候電腦會自動去改檔案夾下找.dmp檔案,建立完directory,
執行expdp備份語句,備份檔案自動產生到directory指定的檔案。
3、 刪除原有使用者
因為,如果不刪除原有使用者,在資料庫還原的時候系統遇到相同的表會跳過,不能實現資料庫還原覆蓋調的目的
首先以超級管理員的身份登入資料庫:
sqlplus system/[email protected] as sysdba;
真正的刪除使用者:
drop user dcuser cascade; --cascade 在oracle資料庫中表示串聯刪除。
4、建立使用者
create uer dcuser identified by dcuser; -- 建立資料庫並設定密碼為:dcuser
grant resource ,connect,dba to dcuser; --為所建立的使用者賦許可權:資源、連結、dba角色。
grant read,write on directory w_dir to dcuser; --賦予使用者dcuser對directory讀和寫的操作的許可權。
5、資料庫還原
做好了上面的準備工作以後,接下來開始真正的資料庫還原
impdp dcuser/[email protected] directory=w_dir dumpfile=database.dmp schemas=dcuser;
6、到此Database Backup還原大功告成!
根據使用者通過資料泵備份還原ORACLE資料庫,