Oracle資料庫備份還原筆記
通過查閱資料知道Oracle備份還原的方式有三種,分別的是匯出/匯入、熱備份和冷備份,匯出/匯入是一種邏輯備份、而熱備份和冷備份是物理備份,[參考資料(https://blog.csdn.net/happylee6688/article/details/13620937])
這里只記錄匯出/匯入的備份和還原的方式,實際作業中遇到一個需求:需要將服務器上的資料庫備份,匯入自己本機的資料庫,相當于把服務器上的對應資料庫實體copy一份兒到本地,主要操作步驟如下,
1. 資料庫匯出
操作位置:需要備份的資料庫,DOS視窗【注意不是SQLPLUS】,
exp RSGL_GB_NEW/RSGL@ORCL file=d:\beifen_20190909.dmp owner=(RSGL_GB_NEW)
這個命令意思是將RSGL_GB_NEW這個庫(密碼是RSGL)匯出,匯出的路徑是d:\beifen_20190909.dmp,
匯出完成之后,將這個檔案拷貝到需要還原的機器上,進行第二步,
2. 創建表空間
操作位置:需要還原資料庫的機器,DOS視窗,登錄之后進入SQLPLUS視窗
C:\Users\zz>sqlplus / as sysdba;
SQL*Plus: Release 11.2.0.1.0 Production on 星期五 9月 27 19:13:21 2019
Copyright (c) 1982, 2010, Oracle. All rights reserved.
ERROR:
ORA-01031: 權限不足
請輸入用戶名: system
輸入口令:
連接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create tablespace RSGL_GB_NEW nologging datafile 'E:\app\oracleServer\product\11.2.0\Oracle\RSGL_GB_NEW.dbf' size 100m autoextend on next 500M maxsize unlimited;
表空間已創建,
登錄了資料庫,選擇一個可以具有創建用戶權限的用戶賬號登錄,創建表空間,接著第三步,
3. 創建用戶,賦予DBA權限
操作位置:SQLPLUS視窗
SQL> CREATE USER RSGL_GB_NEW IDENTIFIED BY RSGL DEFAULT TABLESPACE users;
用戶已創建,
SQL> GRANT CREATE SESSION,CREATE ANY TABLE,CREATE ANY VIEW ,CREATE ANY INDEX,CREATE ANY PROCEDURE, ALTER ANY TABLE, ALTER ANY PROCEDURE,DROP ANY TABLE,DROP ANY VIEW,DROP ANY INDEX, DROP ANY PROCEDURE,SELECT ANY TABLE,INSERT ANY TABLE,UPDATE ANY TABLE,DELETE ANY TABLE TO RSGL_GB_NEW;
授權成功,
SQL> grant DBA to RSGL_GB_NEW;
4. 匯入資料庫
操作位置:DOS視窗【注意:是DOS】
C:\Users\zz>imp RSGL_GB_NEW/RSGL fromuser=RSGL_GB_NEW touser=RSGL_GB_NEW file=D:\RSGL_GN_NEW201909270.dmp ignore=y;
Import: Release 11.2.0.1.0 - Production on 星期五 9月 27 19:31:10 2019
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
連接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
## 開始匯入資料了,,,,,,,,
我這里因為是匯入本地,所以不需要在RSGL_GB_NEW/RSGL后加上@ORCL,網上是這么說的,我還沒搞明白為什么,
5. 常見問題
5.1 sp2-0734錯誤
參考:https://blog.csdn.net/qq_33369215/article/details/53264768
5.2 IMP-00013錯誤
參考: https://blog.csdn.net/breaker892902/article/details/11004495
對Oracle資料庫不熟悉,有可能有沒有說明白的地方,如果實際操作程序中遇到錯誤,可以搜索對應的錯誤提示,大概率是命令寫錯了,
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/39231.html
標籤:Oracle
