從gbk導(dǎo)出的dmp導(dǎo)入到utf8的oracle

第一步,導(dǎo)入表結(jié)構(gòu):
imp userid=xxx/password file yyy.dmp full=y rows=n log=yyy.log
上面語句不會導(dǎo)入數(shù)據(jù),只會導(dǎo)入結(jié)構(gòu),但可能會出現(xiàn)幾個錯誤:
1、表空間不存在,不能創(chuàng)建對象,這個可以建立一個表空間,或者將報錯的腳步修改表空間后重新執(zhí)行。
2、如果按用戶導(dǎo)出,可以將full=y修改為fromuser=fff touser=xxx再導(dǎo)入。
依據(jù)log文件做相應(yīng)處理。同時日志會顯示相關(guān)字符集等信息,來確定字符串長度是否需要修改。

第二步(可選),修改對象表空間
1、生成修改表表空間的語句:
select 'alter table '||table_name||' move tablespace xxx_base;' from user_tables;
2、生成修改索引表空間的語句:
select 'alter index '||index_name||' rebuild tablespace xxx_base;' from user_indexes;

第三步(可選),drop觸發(fā)器
生成drop觸發(fā)器的語句:
select 'drop trigger '||trigger_name||';' from user_triggers;

第四步,修改表字段字符串類型字段的長度
如果在修改長度的列上建立了函數(shù)索引,需要備份索引定義后刪除,然后修改字段長度再重建函數(shù)索引。
set heading off
set space 0
set pagesize 0
set trimout on
set trimspool on
set linesize 2500
spool modify_len.sql
select 'alter table '||table_name||' modify ('||column_name||' '||data_type||'('||ceil(data_length*1.5)||'));'
from user_tab_columns where data_type in ('VARCHAR2','CHAR','NCHAR','NVARCHAR2') and table_name not like 'BIN%' and table_name like 'DSJ%';
spool off
@modify_len.sql

第五步,導(dǎo)入數(shù)據(jù)之前,需要屏蔽所有外鍵
select 'alter table '||t.table_name||' disable constraint '||t.constraint_name||';' from user_constraints t where t.constraint_type='R' order by t.table_name;

第六步,導(dǎo)入數(shù)據(jù)
imp userid=xxx/password file yyy.dmp full=y data_only=y log=yyy1.log

第七步,導(dǎo)入數(shù)據(jù)之后,需要啟用所有外鍵
select 'alter table '||t.table_name||' enable constraint '||t.constraint_name||';' from user_constraints t where t.constraint_type='R' order by t.table_name;


分享題目:從gbk導(dǎo)出的dmp導(dǎo)入到utf8的oracle
網(wǎng)頁鏈接:http://www.muchs.cn/article34/ihpcse.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁設(shè)計公司移動網(wǎng)站建設(shè)、服務(wù)器托管、用戶體驗、動態(tài)網(wǎng)站、自適應(yīng)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司