搜尋此網誌

星期四, 4月 02, 2009

Oracle 10g expdp impdb

如何使用expdb & impdb
1. 建立exp directory
exp 與 expdp 使用上,最大的不同點在於exp directory
傳統的exp 不用建立,直接在執行的語法中宣告即可,而expdb必須先行宣告在資料庫中。
建立的範例:
create directory expdb_dir as '/u01/expdb';

2. 賦與 exp directory 權限
若一般的使用者想使用此目錄,必須賦與相對應的權限
如:
grant read, write on directory expdb_dir to scott;

當然囉,DBA是有無上的權限…所以如果你是DBA身份,那就不用grant。

3. 導出 expdb 資料

有用過舊版exp 的使用者,經常作的不外乎
α、full database export
β、user export
ν、table export

這邊簡單的列出這幾種需求所執行的指令:
●full database export
expdb username/password@dbname directory=expdb_dir dumpfile=fulldb.dmp full=y
●user export
expdb username/password@dbname directory=expdb_dir dumpfile=schema.dmp schemas=scott
●table export
expdb username/password@dbname directory=expdb_dir dumpfile=table.dmp tables=emp.employer


4. 匯入 impdb 資料

匯入資料一般會作的是
α、full database import
β、user import (to another schema)
ν、table import

這邊簡單的列出這幾種需求所執行的指令:

●impdp username/password@dbname directory=expdb_dir dumpfile=fulldb.dmp full=y
●impdp username/password@dbname directory=expdb_dir dumpfile=fulldb.dmp remap_schema=source_schema:dest_schema
●impdp username/password@dbname directory=expdb_dir dumpfile=fulldb.dmp tables=my,big,list,of,tables

另外,還可以更換原先table的tablespace, 只需增加 remap_tablespace=source_tablespace:dest_tablespace即可

expdp 與 impdp 還有許多選項可以使用,請自參考expdp help=y or impdp help=y

星期日, 3月 08, 2009

如何將備份的partition table 還原至現有的table中

如何exp table 中特定的partition

例:將toyman中,fe_tb_cm_session_hist中,partition name為CM_SES_HIST_200812
fe_tb_cm_session_comm_hist中,partition name為CM_SES_COMM_HIST_200812
exp system FILE =toyman-p1.dmp TABLES = toyman.fe_tb_cm_session_hist:CM_SES_HIST_200812,toyman.fe_tb_cm_session_comm_hist:CM_SES_COMM_HIST_200812

我們將12月份的partition export 出來後,必須先在原先的table 中新增partition 為12月份的
不過由於partition table 不能新增一個舊時間的partition, 因此必須利用split partition指令來分割。

ALTER TABLE toyman.FE_TB_CM_SESSION_HIST
SPLIT PARTITION CM_SES_HIST_200901 AT
(TO_DATE(' 2009-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
INTO (PARTITION CM_SES_HIST_200812,
PARTITION CM_SES_HIST_200901);

最後再以imp 的方式將data import 至資料庫

imp system FILE =toyman-p1.dmp TABLES = toyman.fe_tb_cm_session_hist:CM_SES_HIST_200812,toyman.fe_tb_cm_session_comm_hist:CM_SES_COMM_HIST_200812 IGNORE=y

此例中的index 是partition local index, 如果是global index 請記得重新compiler.

星期三, 3月 04, 2009

Oracle DB parameter for OS dependence

###########################################

# for HP-UX DB server only

###########################################

filesystemio_options=setall

hpux_sched_noage=178




This Doc will be continue updated.