oracle資料庫中使用imp和exp命令

2021-05-14 08:54:56 字數 4720 閱讀 3082

200g

左右,資料備份和恢復,以及備份檔案的轉移都成了問題,因為檔案相對比較大了,在檔案備份、轉移、恢復的時間就成倍的增長,不能再向以前一樣始終在本地客戶端操作了。

我將描述一下我自己的操作過程,和其中積累的經驗。

資料庫資訊如下:

使用者:system

密碼:oracle

使用者:test

密碼:oracle

sid:orcl

第一步資料庫的備份:

1、資料匯出:

exp的常用方法如下:

a、將資料庫

orcl

完全匯出

,使用者名稱

system

密碼oracle

匯出到/data/oracle/myoraclebak.dmp

中。命令如下:

exp system/oracle@orclfile=/data/oracle/myoraclebak.dmp full=y log=exp.log b、

將資料庫中

system

使用者與test

使用者的表匯出

命令如下:

exp system/oracle@orclfile=/data/oracle/myoraclebak.dmp owner=(system,test) log=exp.log c、

將資料庫中的表

table1

、table2

匯出命令如下:

exp test/oracle@orcl file=/data/oracle/myoraclebak.dmp tables=(table1,table2) log=exp.log d、

將資料庫中的表

table1

中的字段

filed1

以"00"

打頭的資料匯出

命令如下:

exp test/oracle@orcl file=/data/oracle/myoraclebak.dmp tables=(table1) query=" where filed1 like '00%'" log=exp.log e、

將資料庫中

test

使用者的表匯出到多個檔案,要求單個檔案大小不允許超過

2000m

命令如下:

exp parfile=username.par file=/data/oracle/myoraclebak1.dmp, /data/oracle/myoraclebak2.dmp filesize=2000m log=exp.log

引數檔案

username.par

內容userid=test/oracle@orcl

buffer=8192000

compress=n

grants=y 說明

:username.par

為匯出工具

exp用的引數檔案

,裡面具體引數可以根據需要去修改

filesize

指定生成的二進位制備份檔案的最大位元組數。

f、增量匯出

命令如下:

exp   system/manager@svr_ora   inctype=incremental   file=d:/incremental.dmp 2、

我使用的命令如下:

more exp.sh

exp test/oracle@orclfile=/data/oracle/myoraclebak.dmp full=y log=exp.log

nohup ./exp sh &

程序執行時間

24小時左右,最終

myoraclebak.dmp

檔案大小

32g左右。

第二步資料庫匯入:

3、資料的匯入a、將

myoraclebak.dmp

中的資料匯入

neworcl

資料庫中。

命令如下:

imp test/oracle@neworcl file=myoraclebak.dmp full=y ignore=y log=imp.log buffer=999999

在後面加上

ignore=y

是忽略警告錯誤。b、將

myoraclebak.dmp

中的表table1

匯入命令如下:

imp test/oracle@neworcl file= myoraclebak.dmptables=(table1) ignore=y log=imp.log buffer=999999

c、匯入乙個或一組指定使用者所屬的全部表、索引和其他物件

命令如下:

imp system/oracle@neworcl file=myoraclebak.dmp log=imp.log fromuser=(test1,testuser2)

d、將乙個使用者所屬的資料匯入另乙個使用者

命令如下:

imp system/oracle@neworcl file=myoraclebak.dmp log=imp.log fromuser=test touser=testuser2

e、從多個檔案匯入

命令如下:

imp system/oracle@neworcl file=(myoraclebak1.dmp, myoraclebak2.dmp) log= imp.log, filesize=1g full=y

f、增量匯入

命令如下:

imp   system/manager@client_data   inctype=restore   ignore=y   full=y   file=d:/incremental.dmp 4、

我使用的命令如下:

more imp.sh

imp test/oracle@orcl file=

myoraclebak.dmp

full=y ignore=y log=imp.log buffer=999999

nohup ./imp.sh &

程序執行時間

10小時左右。匯入完畢後,資料占用空間

200g左右

備註1:1

、給使用者增加匯入資料許可權的操作第一,

啟動sql*puls

第二,以

system/manager

登陸第三,

create user

使用者名稱identified by

密碼(如果已經建立過使用者,這步可以省略)

第四,grant create user,drop user,alter user ,create any view ,

drop any view,exp_full_database,imp_full_database,

dba,connect,resource,create sessionto

使用者名字

2、建立表空間指令碼

--need change url :'/mnt/data/database/sbap_conf.dbf',size :2048m

create tablespace sbap_conf datafile

'/mnt/data/database/sbap_conf.dbf' size 2048m autoextend on next 2048m maxsize unlimited

nologging

permanent

extent management local

blocksize 8k

segment space management auto

flashback off;

執行過程如下:

[oracle@rehl-oracle ~]$ sqlplus

sql*plus: release 10.2.0.1.0 - production on sun dec 20 06:57:31 2009

enter user-name: /as sysdba

connected to:

oracle database 10g enterprise edition release 10.2.0.1.0 - 64bit production

with the partitioning, olap and data mining options

sql>

@/data/tablespace.sql備註2

:drop table mytable

truncate table (schema)table_name

oracle10g

**站及徹底刪除

table : drop table xx purge

drop

後的表被放在**站

(user_recyclebin)

裡,而不是直接刪除掉。這樣,**站裡的表資訊就可以被恢復,或徹底清除。 1.

通過查詢**站

user_recyclebin

獲取被刪除的表資訊,然後使用語句

flashback table to before drop [rename to ];

將**站裡的表恢復為原名稱或指定新名稱,表中資料不會丟失。

若要徹底刪除表,則使用語句:

drop table purge; 2.

清除**站裡的資訊

清除指定表:

purge table ;

清除當前使用者的**站:

purge recyclebin;

清除所有使用者的**站:

purge dba_recyclebin;

oracle 還原資料庫 imp

imp c nvs 111111 file e 專案 ishow web buckup database oracle初始資料庫匯入 20170714 expdata 20170714.dump log e 專案 ishow web buckup database oracle初始資料庫匯入 201...

Oracle資料庫匯出 exp 匯入 imp

exp damp 檔案,方便資料遷移。但這個過程不能太長,以免回滾段和聯機日誌消耗完 imp 將exp dmp檔案上載到資料庫內。buffer 上載資料緩衝區,以位元組為單位,預設依賴作業系統 commit 上載資料緩衝區中的記錄上載後是否執行提交 feeback 顯示處理記錄條數,預設為0,即不顯...

oracle資料庫匯出 exp 匯入 imp)

單錶備份 前提庫的結構是一樣的 匯出 exp 使用者名稱 密碼 連線字串 grants y tables stu file c 檔名.dmp 匯入 imp 使用者名稱 密碼 連線字串 ignore y tables stu full n file c 檔名.dmp 其中stu是你要的表名 全庫導 匯...