不同字符集倒庫的方法
2024-07-21 02:11:18
供稿:網友
本文來源于網頁設計愛好者web開發社區http://www.html.org.cn收集整理,歡迎訪問。
第一步:exp 原 us7ascii數據庫中的scott用戶。
第二步:exp 原us7ascii 數據庫中的zhaoboyi用戶。
第三步:create new database(character set simplified chinese_china.zhs16gbk),
所有的路徑與原
數據庫相同。
第四步:將zhs16gbk 中的init。ora copy init。ora。bak。
第五步:將us7ascii 中的init。ora copy zhs16gbk 修改相應參數。
第六步:生成zhs16gbk 中的scott 用戶,授權,exp zhs16gbk 中的scott 用戶。
第七步: 生成zhs16gbk 中的zhaoboyi 用戶,exp zhs16gbk 中的zhaoboyi 用戶。
第八步:用ultraedit 分別打開(us7ascii)以及(zhs16gbk)scott 用戶,將前5行中的u
s7ascii 不同處改掉。
第九步:相應的做zhaoboyi 用戶。
第十步:在zhs16gbk中,執行sys 用戶的owaload。sql ,對htp。p授權。
第十一步:做imp,把原有的數據庫倒入到新的數據庫。
第十二步:解決大字段問題。
首先在原數據庫中執行存儲過程 fwrite_clob_niu,將含有大字段的表生成到文件中,接著
,在新數據庫中編譯執行fupdate_clob_text,
將大字段倒回到新數據庫中。
附錄:
1。存儲過程:fwrite——clob——niu
procedure fwrite_clob_niu as
cursor c_lt is
select c.text,c.info_id
from info_ctext c
where info_id <= 120
--change7.16 where info_id <=100
order by info_id asc;
/*
1000-1100 f
1100-1600 ok
1600-1630 ok
1629-1640 ok
1640-1660 f
1660-1668 ok
1669 f
1670-1750 ok
*/
str varchar2(32767) := null;
position integer := 1;
new_position integer := 1;
pat varchar2(80) := 'd:/writeclob';
--change716 pat varchar2(80) := '/export/home0/ora8i/doc/ch';
save_file utl_file.file_type;
result boolean := false;
dir_delimiter varchar2(200) := '/';
--change 7.16 dir_delimiter varchar2(200) := '/'; -- note: use '/' for win
dows nt
p_filename varchar2(200);
v_offset integer;
v_amount integer;
v_buffer varchar2(30240);
begin
v_amount := 30240;
if substr( pat, length( pat ), 1 ) != dir_delimiter then
pat := pat || dir_delimiter; end if;
begin
for r in c_lt
loop
if r.text is not null then
p_filename := r.info_id ||'.dat';
new_position:=1;
position:=1;
save_file := utl_file.fopen( pat, p_filename, 'w' );
if dbms_lob.instr( r.text, chr(10), position ) = 0 then
begin
v_offset := 1;
v_buffer := '';
loop
dbms_lob.read(r.text,v_amount,v_offset,v_buffer);
v_offset := v_offset + v_amount;
utl_file.put( save_file, v_buffer );
-- htp.p(v_buffer);
-- htp.p('jjjj');
end loop;
exception
when no_data_found then
null;
end;
-- htp.p('111');
-- str := dbms_lob.substr( r.text,1)||chr(10);
-- htp.p(str);
end if;
while( new_position != 0 )
loop
new_position := dbms_lob.instr( r.text, chr(10), position );
str := dbms_lob.substr( r.text, new_position - position, position );
-- htp.p('str=');
-- htp.p(str);
position := new_position + 1;
--change 7.17 if new_position != 0 then
utl_file.put_line( save_file, replace( str, chr(10), null ) );
-- else
-- utl_file.put_line( save_file, str );
-- change 7.17
-- htp.p(new_position);
-- end if;
end loop;
utl_file.fclose(save_file);
htp.p('<center><h2>the file '||p_filename||' generated!</h2></center>');
end if;
end loop;
exception
when no_data_found then
htp.p('<center><h2>the file '||p_filename||' failed!</h2></center>');
end;
end fwrite_clob_niu;
附錄二:存儲過程fupdate_clob_text
procedure fupdate_clob_text as
cursor c_lt is
select c.text,c.info_id
from info_ctext c
-- where info_id = 112
where ((info_id >= 1 and info_id <= 30) or
(info_id >=30 and info_id <= 60) or
(info_id >=60 and info_id <= 90) or
(info_id >=90 and info_id <= 120))
/* --change 716 where type not in ('b','c','v','a','e') and ((info_id >=10000
and info_id <20000) or
(info_id >=1100 and info_id <1601) or
(info_id >=1600 and info_id <1630) or
(info_id >=1660 and info_id <1668) or
info_id >=1670 or
(info_id >=0 and info_id <501))
*/
order by info_id asc;
/*
1000-1100 f
1100-1600 ok
1600-1630 ok
1629-1640 ok
1640-1660 f
1660-1668 ok
1669 f
1670-1750 ok
*/
tmp clob;
pat varchar2(80) := 'd:/writeclob';
-- change 7.16 pat varchar2(80) := '/export/home0/ora8i/doc/ch';
save_file utl_file.file_type;
result boolean := false;
dir_delimiter varchar2(200) := '/';
-- change 7.16 dir_delimiter varchar2(200) := '/'; -- note: use '/' for w
indows nt
p_filename varchar2(200);
begin
htp.p('我們');
if substr( pat, length( pat ), 1 ) != dir_delimiter then
pat := pat || dir_delimiter; end if;
for r in c_lt
loop
begin
p_filename :=to_char(r.info_id)||'.dat';
update info_ctext set text = ' '
where info_id=r.info_id;
commit;
select text into tmp from info_ctext
where info_id = r.info_id for update;
-- dbms_lob.trim( tmp, 0 );
result := load_file( pat, p_filename, tmp );
if result then
update info_ctext set text = tmp
where info_id=r.info_id;
commit;
end if;
end;
end loop;
exception
when no_data_found then
htp.p('<center><h2>the file '||p_filename||' failed!</h2></center>');
end fupdate_clob_text;
附錄三:新數據庫字符集
nls——lang
simplified chinese_china.zhs16gbk
原數據庫字符集
american_america.us7ascii.
______________________________________
===================================================================
新浪免費電子郵箱 (http://mail.sina.com.cn)
訂閱手機短信頭條新聞,天天獎多款時尚手機! (http://dailynews.sina.com.cn/c/272235.html)
訂閱手機短信頂級新聞每天得新款手機大獎! (http://dailynews.sina.com.cn/c/266499.html)