標籤:
---恢複內容開始---
現在大型企業一般都用Oracle資料庫,Oracle資料庫在一般採用expdp,impdp 匯出匯入資料,但是在操作中經常會遇到一些問題。下面來淺析這些問題。
1. 匯出資料
一般匯出資料的時候需要建立一個目錄位址
select * from dba_directories; --查詢所有目錄位址
create or replace directory winqt_dump as ‘/home/front/dmpfile‘; --建立目錄位址
grant read,write on directory winqt_dump to qtdb; --給目錄位址賦讀寫權限
drop directory dumpwinqt; --刪除目錄位址
select username,default_tablespace from dba_users; -- 查詢使用者下面的資料表空間
select * from user_indexes; --查詢使用者下所有索引
select table_name from user_tables where NUM_ROWS > 0; --查詢有資料的表
注意在 資料庫賦值許可權的時候需要用oracle使用者登入。
expdp qtdb/qtdb dumpfile=20150907test.dmp directory=dumpwinqt schemas=qtdb logfile=export.log; --匯出資料庫
touch export.log ; --匯出日誌路徑
chomd 777 export.log; --給日誌賦許可權
如所有
問題1:
2. 匯入資料
impdp hsqtdb/hsqtdb dumpfile=20150217qtdb.dmp directory=dumpwinqt remap_schema=hnqtdb:hsqtdb nologfile=true; --匯入資料
匯出用expdp 對應的匯入就用impdp 否則會報如下錯誤:
如果用空表存在 最好用expdp 匯出 因為oracle11g中有個新特性,當表無資料時,不分配segment,以節省空間的,所以exp導不出空表。解決的辦法是用expdp
3. 建立資料庫執行個體
sqlplus / as sysdba
drop user c3front cascade;
create user c1ecifgp identified by c1ecifgp default tablespace USERS temporary tablespace TEMP ;
grant connect , resource , dba to c1ecifgp ;
Oracle 資料庫操作