第一步: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(
the file ||p_filename|| generated!
end if;
end loop;
exception
when no_data_found then
htp.p(
the file ||p_filename|| failed!
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(
the file ||p_filename|| failed!
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)