Oracle數據導入導出,定時備份

  1. 導出數據命令行
    文件 expdata.bat parfile指向expdata.par文件
    exp parfile=D:\exp\expdata.par file=txgl.dmp filesize=600M log=dl.log

    文件expdata.par
    <a target=_blank href="mailto:userid=txgl/123456@ZZSorcl">userid=txgl/123456@ZZSorcl</a>
    buffer=8192000
    compress=n
    grants=n
    
    
  2. 導入數據
    文件impdata.bat
    imp system/password@orcl fromuser=sntap touser=snt parfile=impdata.par
    


    文件impdata.par
    file=oraclebak.dmp
    buffer=2048000
    ignore=n
    commit=y
    

  3. 導入數據 不寫par
    imp system/password@orcl fromuser=from_user touser=to_user file=E:\test\bak\test.dmp log=E:\test\bak\test.log buffer=2048000 ignore=y commit=y

    如果是不同的表空間,touser要一個權限,不然clob類型字段的表會出錯:GRANT UNLIMITED TABLESPACE TO TO_USER

  4. Windows定時備份
    新建bat文件 內容:
    @echo off   
    echo 正在備份 Oracle 數據庫,請稍等......   
    set riqi=%date:~0,4%%date:~5,2%%date:~8,2%
    exp system/password@orcl file=E:\oraclebak\oraclebak%riqi%.dmp log=F:\oraclebak\oraclebak%riqi%.log buffer=960000  
    echo 任務完成!
    echo 開始清理備份文件
    forfiles /p "E:\oraclebak" /s /m *.* /d -6 /c "cmd /c del @path"

    在window計劃任務裏面添加定時任務,設置備份的間隔時間,每天執行的時間,在“操作”選項卡里面選擇新建好的bat文件。“常規”選項卡里面選擇“不管用戶是否登錄都要運行”


-------------------------------------------------------------------------------------------------------------------------------------------
創建Oracle用戶:

create user newuser
  identified by "password"
  --default tablespace TBS_DATA01 
  --temporary tablespaceTBS_DATA01_temp 
  profile DEFAULT
  --表空間
  quota unlimited on newuser;
-- Grant/Revoke role privileges
--用戶
grant connect to newuser;
-- Grant/Revoke system privileges
grant create any index to newuser;
grant create any sequence to newuser;
grant create any table to newuser;
grant create any trigger to newuser;
grant create any view to newuser;
grant create procedure to newuser;
grant select any dictionary to newuser;
grant select any sequence to newuser;
GRANT UNLIMITED TABLESPACE TO newuser;


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章