??xml version="1.0" encoding="utf-8" standalone="yes"?>久久99影院,日韩久久精品网,欧美日韩高清区http://www.aygfsteel.com/shypwang/category/25146.htmlzh-cnSat, 25 Aug 2007 10:00:22 GMTSat, 25 Aug 2007 10:00:22 GMT60理解ORACLE数据库字W集http://www.aygfsteel.com/shypwang/articles/139217.html妖h妖hSat, 25 Aug 2007 01:10:00 GMThttp://www.aygfsteel.com/shypwang/articles/139217.htmlhttp://www.aygfsteel.com/shypwang/comments/139217.htmlhttp://www.aygfsteel.com/shypwang/articles/139217.html#Feedback0http://www.aygfsteel.com/shypwang/comments/commentRss/139217.htmlhttp://www.aygfsteel.com/shypwang/services/trackbacks/139217.html

理解ORACLE数据库字W集

耿立?br>Q中国科学院计算机网l信息中心,北京100080Q?/font>


一Q引a

    ORACLE数据库字W集Q即Oracle全球化支?Globalization Support)Q或卛_家语a支持QNLSQ其作用是用本国语言和格式来存储、处理和索数据。利用全球化支持QORACLE为用h供自q(zhn)的数据 库母语环境,诸如日期格式、数字格式和存储序列{。Oracle可以支持多种语言及字W集Q其中oracle8i支持48U语a?6个国家地域?29 U字W集Q而oracle9i则支?7U语a?8个国家地域?35U字W集。由于oracle字符集种cdQ且在存储、检索、迁Uoracle数据 时多个环节与字符集的讄密切相关Q因此在实际的应用中Q数据库开发和理人员l常会遇到有关oracle字符集方面的问题。本文通过以下几个斚w阐述Q? 对oracle字符集做要分?/p>

二.字符集基本知?/strong>

2.1字符?br>    实质是按照一定的字符~码Ҏ(gu)Q对一l特定的W号Q分别赋予不同数值编码的集合。Oracle数据库最早支持的~码Ҏ(gu)是US7ASCII?br>    Oracle的字W集命名遵@以下命名规则:
    <Language><bit size><encoding>
    ?  <语言><比特位数><~码>
    比如: ZHS16GBK表示采用GBK~码格式?6位(两个字节Q简体中文字W集

2.2字符~码Ҏ(gu)
2.2.1 单字节编?br>    Q?Q单字节7位字W集Q可以定?28个字W,最常用的字W集为US7ASCII
    Q?Q单字节8位字W集Q可以定?56个字W,适合于欧z大部分国家
    例如QWE8ISO8859P1(西欧?位、ISO标准8859P1~码)
2.2.2 多字节编?br>    Q?Q变长多字节~码
    某些字符用一个字节表C,其它字符用两个或多个字符表示Q变长多字节~码常用于对亚洲语言的支持,   例如日语、汉语、印地语{?br>    例如QAL32UTF8Q其中AL代表ALL,指适用于所有语aQ、zhs16cgb231280
    Q?Q定长多字节~码
    每一个字W都使用固定长度字节的编码方案,目前oracle唯一支持的定长多字节~码是AF16UTF16Q也是仅用于国家字符?br>2.2.3 unicode~码
    Unicode是一个涵盖了目前全世界用的所有已知字W的单一~码Ҏ(gu)Q也是说Unicode为每一个字W提供唯一的编码。UTF-16? unicode?6位编码方式,是一U定长多字节~码Q用2个字节表CZ个unicode字符QAF16UTF16是UTF-16~码字符集?br>    UTF-8是unicode?位编码方式,是一U变长多字节~码Q这U编码可以用1??个字节表CZ个unicode字符QAL32UTF8QUTF8、UTFE是UTF-8~码字符?/p>

2.3 字符集超U?br>    当一U字W集Q字W集AQ的~码数值包含所有另一U字W集Q字W集BQ的~码数|q且两种字符集相同编码数g表相同的字符Ӟ则字W集A是字W集B的超U,或称字符集B是字W集A的子集?br>    Oracle8i和oracle9i官方文档资料中备有子?对照表(subset-superset pairsQ,例如QWE8ISO8859P1是WE8MSWIN1252的子集。由于US7ASCII是最早的Oracle数据库编码格式,因此有许? 字符集是US7ASCII的超集,例如WE8ISO8859P1、ZHS16CGB231280、ZHS16GBK都是US7ASCII的超集?/p>

2.4 数据库字W集Qoracle服务器端字符集)
    数据库字W集在创建数据库时指定,在创建后通常不能更改。在创徏数据库时Q可以指定字W集(CHARACTER SET)和国家字W集(NATIONAL CHARACTER SET)?br>2.4.1字符?br>    (1)用来存储CHAR, VARCHAR2, CLOB, LONG{类型数?br>    (2)用来标示诸如表名、列名以及PL/SQL变量{?br>    (3)用来存储SQL和PL/SQLE序单元{?br>2.4.2国家字符集:
    (1)用以存储NCHAR, NVARCHAR2, NCLOB{类型数?br>    (2)国家字符集实质上是ؓoracle选择的附加字W集Q主要作用是Z增强oracle的字W处理能力,因ؓNCHAR数据cd可以提供对亚z用定 长多字节~码的支持,而数据库字符集则不能。国家字W集在oracle9i中进行了重新定义Q只能在unicode~码中的AF16UTF16和UTF8 中选择Q默认值是AF16UTF16
2.4.3查询字符集参?br>    可以查询以下数据字典或视图查看字W集讄情况
    nls_database_parameters、props$、v$nls_parameters
    查询l果中NLS_CHARACTERSET表示字符集,NLS_NCHAR_CHARACTERSET表示国家字符?br>2.4.4修改数据库字W集
    按照上文所_数据库字W集在创建后原则上不能更攏V如果需要修改字W集Q通常需要导出数据库数据Q重建数据库Q再导入数据库数据的方式来{换,或通过 ALTER DATABASE CHARACTER SET语句修改字符集,但创建数据库后修改字W集是有限制的,只有新的字符集是当前字符集的集时才能修Ҏ(gu)据库字符集,例如UTF8是US7ASCII 的超集,修改数据库字W集可用ALTER DATABASE CHARACTER SET UTF8?/p>

2.5 客户端字W集QNLS_LANG参数Q?/strong>
2.5.1客户端字W集含义
    客户端字W集定义了客L(fng)字符数据的编码方式,M发自或发往客户端的字符数据均用客L(fng)定义的字W集~码,客户端可以看作是能与数据库直接连接的各种应用Q例如sqlplus,exp/imp{。客L(fng)字符集是通过讄NLS_LANG参数来设定的?br>2.5.2 NLS_LANG参数格式
    NLS_LANG=<language>_<territory>.<client character set>
    Language:昄oracle消息,校验Q日期命?br>    TerritoryQ指定默认日期、数字、货币等格式
    Client character setQ指定客L(fng)用的字符?br>    例如QNLS_LANG=AMERICAN_AMERICA.US7ASCII 
    AMERICAN是语aQAMERICA是地区,US7ASCII是客L(fng)字符?br>2.5.3客户端字W集讄Ҏ(gu)
     1)UNIX环境
         $NLS_LANG=“simplified chinese”_china.zhs16gbk
         $export NLS_LANG
         ~辑oracle用户的profile文g
    2)Windows环境
         ~辑注册?br>         Regedit.exe---HKEY_LOCAL_MACHINE---SOFTWARE---ORACLE—HOME0
2.5.4 NLS参数查询
    Oracle提供若干NLS参数定制数据库和用户Z适应本地格式Q例如有NLS_LANGUAGE,NLS_DATE_FORMAT,NLS_CALENDER{,可以通过查询以下数据字典或v$视图查看?br>    NLS_DATABASE_PARAMETERS--昄数据库当前NLS参数取|包括数据库字W集取?br>    NLS_SESSION_PARAMETERS--昄由NLS_LANG 讄的参敎ͼ或经qalter session 改变后的参数|不包括由NLS_LANG 讄的客L(fng)字符集)
    NLS_INSTANCE_PARAMETE--昄由参数文件init<SID>.ora 定义的参数V$NLS_PARAMETERS--昄数据库当前NLS参数取?br>2.5.5修改NLS参数
    使用下列Ҏ(gu)可以修改NLS参数
    Q?Q修改实例启动时使用的初始化参数文g
    Q?Q修改环境变量NLS_LANG
    Q?Q用ALTER SESSION语句Q在oracle会话中修?br>    Q?Q用某些SQL函数
    NLS作用优先U别QSql function>alter session>环境变量或注册表>参数文g>数据库默认参?/p>

三.导入/导出与字W集转换

3.1 EXP/IMP
    Export ?Import 是一对读写Oracle数据的工兗Export ?Oracle 数据库中的数据输出到操作pȝ文g? Import 把这些文件中的数据读到Oracle 数据库中Q由于用exp/impq行数据q移Ӟ数据从源数据库到目标数据库的q程中有四个环节涉及到字W集Q如果这四个环节的字W集不一_会发生 字符集{换?/p>

EXP                       

IMP                       

    四个字符集是
   Q?Q源数据库字W集
   Q?QExportq程中用户会话字W集Q通过NLS_LANG讑֮Q?br>   Q?QImportq程中用户会话字W集Q通过NLS_LANG讑֮Q?br>   Q?Q目标数据库字符?/p>

3.2导出的{换过E?br>    在Exportq程中,如果源数据库字符集与Export用户会话字符集不一_会发生字W集转换Qƈ在导出文件的头部几个字节中存储Export用户会话字符集的ID受在q个转换q程中可能发生数据的丢失?br>? 如果源数据库使用ZHS16GBKQ而Export用户会话字符集用US7ASCIIQ由于ZHS16GBK?6位字W集,而US7ASCII?? 字符集,q个转换q程中,中文字符在US7ASCII中不能够扑ֈ对等的字W,所以所有中文字W都会丢p变?#8220;?? ”形式Q这栯{换后生成的Dmp文g已经发生了数据丢失?br>因此如果x导出源数据库数据,则Exportq程中用户会话字W集应等于源数据库字W集或是源数据库字符集的集

3.3导入的{换过E?/strong>
    Q?Q确定导出数据库字符集环?br>    通过d导出文g_可以获得导出文g的字W集讄
    Q?Q确定导入session的字W集Q即导入Session使用的NLS_LANG环境变量
    Q?QIMPd导出文g
    d导出文g字符集IDQ和导入q程的NLS_LANGq行比较
    Q?Q如果导出文件字W集和导入Session字符集相同,那么在这一步骤内就不需要{换,如果不同Q就需要把数据转换为导入Session使用的字W集。可以看出,导入数据到数据库q程中发生两ơ字W集转换
    W一?导入文g字符集与导入Session使用的字W集之间的{换,如果q个转换q程不能正确完成QImport向目标数据库的导入过E也׃能完成?br>    W二?导入Session字符集与数据库字W集之间的{换?br>    然?oracle8i的这U{换只能在单字节字W集之间q行,oracle8i导入Session不支持多字节字符集之间的转换Q因此ؓ了避免第一ơ{ 换,导入Session使用的NLS_LANG与导出文件字W集相同Q第二次转换Q通过SQL*NetQ支持Q何两U字W集。以上情况在Oracle9i 中略有不?/p>

四.q问题

    oracle在数据存储、迁U过E中l常发生字符q问题Q归根到底是׃字符集用不当引赗下面以使用客户端sqlplus向数据库插入数据和导?导出QEXP/IMPQ过Eؓ例,说明q产生的原因?/p>

4.1使用客户端sqlplus向数据库存储数据
    q个q程存在3个字W集讄
    Q?Q客L(fng)应用字符?br>    Q?Q客L(fng)NLS_LANG参数讄
    Q?Q服务器端数据库字符?Character Set)讄
    客户端应用sqlplus中能够显CZ么样的字W取决于客户端操作系l语a环境(客户端应用字W集)Q但在应用中录入q些字符后,q些字符能否在数据库? 正常存储Q还与另外两个字W集讄紧密相关Q其中客L(fng)NLS_LANG参数主要用于字符数据传输q程中的转换判断。常见的q大致有两U情形:
    Q?Q汉字变成问?#8220;Q?#8221;Q?br>当从字符集A 转换成字W集BӞ如果转换字符之间不存在对应关p,NLS_LANG使用替代字符“Q?#8221;替代无法映射的字W?br>    Q?Q汉字变成未知字W(虽然有些是汉字,但与原字W含义不同)
转换存在对应关系Q但字符集A 中的字符~码与字W集B 中的字符~码代表不同含义

4.2发生q原因 
    q产生是由于几个字W集之间转换不匹配造成Q分以下几种情况Q?br>    Q注Q字W集之间如果不存在子集、超集对应关pL的情况不予考虑Q因U情况下字符集之间{换必产生qQ?nbsp;  
    1Q服务器端数据库字符集与客户端应用字W集相同Q与客户端NLS_LANG参数讄不同
    如果客户端NLS_LANG字符集是其它两种字符集的子集Q{换过E将出现q?br>    解决Ҏ(gu)Q将三种字符集设|成同一字符集,或NLS_LANG字符集是其它两种字符集的集
    2Q服务器端数据库字符集与客户端NLS_LANG参数讄相同Q与客户端应用字W集不同
    如果客户端应用字W集是其它两U字W集的超集时Q{换过E将出现qQ但对于单字节编码存储中文问题,可参看本文第5章节的分?br>    3Q客L(fng)应用字符集、客L(fng)NLS_LANG参数讄、服务器端数据库字符集互不相?br>    此种情况较ؓ复杂Q但三种字符集之间只要有不能转换的字W,则必产生q

4.3导入/导出q程出现q原因
    q个q程存在4个字W集讄Q在3.1章节中已分析
   Q?Q源数据库字W集
   Q?QEXPq程中NLS_LANG参数
   Q?QIMPq程中NLS_LANG参数
   Q?Q目标数据库字符?br>    出现q原因
    1Q当源数据库字符集不{于EXPq程中NLS_LANG参数Q且源数据库字符集是EXPq程中NLS_LANG的子集,才能保证导出文g正确Q其他情况则导出文g字符q
    2QEXPq程中NLS_LANG字符集不{于IMPq程中NLS_LANG字符集,且EXPq程中NLS_LANG字符集是IMPq程中NLS_LANG字符集的子, 才能保证W一ơ{换正常,否则W一ơ{换中出现q?br>    3Q如果第一ơ{换正常,IMPq程中NLS_LANG字符集是目标数据库字W集的子集或相同Q才能保证第二次转换正常Q否则则W二ơ{换中出现q

五.单字节编码存储中文问?/strong>

    ׃历史的原因,早期的oracle没有中文字符集(如oracle6、oracle7? oracle7.1Q?但有的用户从那时起就使用数据库了Qƈ用US7ASCII字符集存储了中文Q或是有的用户在创徏数据库时Q不考虑清楚Q随意选择一 个默认的字符集,如WE8ISO8859P1或US7ASCIIQ而这两个字符集都没有汉字~码Q虽然有些时候选用q种字符集好象也能正怋用,但用q种 字符集存储汉字信息从原则上说是错误的,它会l数据库的用与l护带来一pd的麻烦?br>    正常情况下,要将汉字存入数据库,数据库字W集必须支持中文Q而将数据库字W集讄为US7ASCII{单字节字符集是不合适的。US7ASCII字符? 只定义了128个符Pq不支持汉字。另外,如果在SQL*PLUS中能够输入中文,操作pȝ~省应该是支持中文的Q但如果在NLS_LANG中的字符? 讄为US7ASCIIQ显然也是不正确的,它没有反映客L(fng)的实际情c但在实际应用中汉字昄却是正确的,q主要是因ؓOracle查数据库与客? 端的字符集设|是同样的,那么数据在客户与数据库之间的存取q程中将不发生Q何{换,但是q实际上D了数据库标识的字W集与实际存入的内容是不相符的? 而在SELECT的过E中QOracle同样查发现数据库与客L(fng)的字W集讄是相同的Q所以它也将存入的内容原不动地传送到客户端,而客L(fng)操作p? l识别出q是汉字~码所以能够正显C?br>    在这个例子中Q数据库与客L(fng)都没有设|成中文字符集,但却能正常显CZ文,从应用的角度看好象没问题。然而这里面却存在着极大的隐(zhn),比如在应用length或substr{字W串函数Ӟ可能得到意外的l果?br>    对于早期使用US7ASCII字符集数据库的数据迁Udoracle8i/9i中(使用zhs16gbkQ,׃原始数据已经按照US7ASCII格式? 储,对于q种情况Q可以通过使用Oracle8i的导出工P讄导出字符集ؓUS7ASCIIQ导出后使用UltraEdit{工h开dmp文gQ修 改第二、三字符Q修?0001 ?354,q样可以将US7ASCII字符集的数据正确导入到ZHS16GBK的数据库中?/p>

六.l束?/strong>

    Z避免在数据库q移q程中由于字W集不同D的数据损失,oracle提供了字W集扫描工具Qcharacter set scannerQ,通过q个工具我们可以试在数据迁U过E中׃字符集{换可能带来的问题Q然后根据测试结果,定数据q移q程中最?jng)_W集解决Ҏ(gu)?/p>


参考文?/strong>
[1]Biju Thomas , Bob Bryla《oracle9i DBA基础I 学习指南》电(sh)子工业出版社 2002
[2]|站 http://www.itpub.net



妖h 2007-08-25 09:10 发表评论
]]>
动态徏表的权限分析(?http://www.aygfsteel.com/shypwang/articles/138917.html妖h妖hThu, 23 Aug 2007 11:19:00 GMThttp://www.aygfsteel.com/shypwang/articles/138917.htmlhttp://www.aygfsteel.com/shypwang/comments/138917.htmlhttp://www.aygfsteel.com/shypwang/articles/138917.html#Feedback0http://www.aygfsteel.com/shypwang/comments/commentRss/138917.htmlhttp://www.aygfsteel.com/shypwang/services/trackbacks/138917.html阅读全文

妖h 2007-08-23 19:19 发表评论
]]>
oracle sql 学习W记http://www.aygfsteel.com/shypwang/articles/138788.html妖h妖hThu, 23 Aug 2007 04:31:00 GMThttp://www.aygfsteel.com/shypwang/articles/138788.htmlhttp://www.aygfsteel.com/shypwang/comments/138788.htmlhttp://www.aygfsteel.com/shypwang/articles/138788.html#Feedback0http://www.aygfsteel.com/shypwang/comments/commentRss/138788.htmlhttp://www.aygfsteel.com/shypwang/services/trackbacks/138788.htmlselect * from v$version --查看版本
-----------------------------------------------------------------------------------
create table tempppp
(exception number(1)
)
insert into tempppp values(1)

select "EXCEPTION" from tempppp
select "exception" from tempppp --failed
引征区分大小写,数据字典里都为大?br>select exception from tempppp
insert into tempppp values('2')

-----------------------------------------------------------------------------------

<<ppp>>
declare
Orgid number(19):=-1;--变量名不要和表列名相?br> v_tmp number(19);
begin
select count(orgid) into v_tmp from organization where
orgid=Orgid;
Dbms_Output.put_line(v_tmp);
select count(orgid) into v_tmp from organization where
orgid=ppp.Orgid;
end;

--------------------------------------------------------------------------
declare
inxx varchar(2):='N ';--都ؓ定长采用填充I格?br> --inxx varchar(2):='N ';--有一个ؓ变长采用非填充空格式
v_tmp number(19);
begin
select count(1) into v_tmp from dcperioddetail where inuse=inxx;
Dbms_Output.put_line(v_tmp);

end;


----------------------------------------------------------------------------
--伪列
select productseq.nextval from dual
select productseq.currval from dual
--只有发出臛_一条nextval才能在会话中讉Kcurval

select rowid from product
select rowidtochar(rowid) from product

select prodid from product where rownum<3


SELECT contactid ,level
FROM contact
--where contactid=100000020
START WITH contactid = (
select b.contactid
from usr b
where b.userid=1)
CONNECT BY parentcontactid = PRIOR contactid

------------------------------------------------------------------------------------
--常用函数
select upper(prodcode) from product where prodcode like 'qs040089'
--substr
select substr('qs040089',0) from dual
select substr('qs040089',1) from dual
select substr('qs040089',2) from dual
select substr('qs040089',-3) from dual
select substr('qs040089',1,1.5) from dual

--instr
select instr('qs040089','04') from dual
select instr('qs040089','04',4) from dual
select instr('qs040089','04',-1) from dual
--length
select length('qs040089') from dual

--decode
select decode(prodcode,'qs040089',1,2) from product where prodcode like
'qs040089'

--trunc
select trunc(datelastupdated),datelastupdated from product where
prodcode like 'qs040089'

--round
select round(datelastupdated),datelastupdated from product where
prodcode like 'qs040089'

--to_char
select to_char(sysdate,'DD-MM-YY HH24:MI:SS') from dual

--to_date
declare
v_CurrentDate DATE;
begin

v_CurrentDate :=to_date('11 07, 1973','MM DD, YYYY');
Dbms_Output.put_line(v_CurrentDate);
end;

--nullif
select nullif(1,12) from dual
select nullif(12,1) from dual
select nullif(12,12) from dual

--nvl
select nvl(2,1) from dual
select nvl(null,1) from dual

select user from dual
select USERENV('TERMINAL'),USERENV('LANGUAGE') from dual


--CURSOR
游标----------------------------------------------------------------



--sql
游标------------------------------------------------------------------
begin
update product
set prodcode='8800000000000'
where prodcode='qs04008911111';

if SQL%NOTFOUND THEN
DBMS_OUTPUT.put_line(11111);
end if;
end;

begin
update product
set prodcode='8800000000000'
where prodcode='qs04008911111';

if SQL%ROWCOUNT=0 THEN
DBMS_OUTPUT.put_line(11111);
end if;
end;

DECLARE
v_tmp product%rowtype;
begin
select * into v_tmp from product where prodid=-1;
--SELECT INTO 未找C报错Q?br> if SQL%notfound THEN
DBMS_OUTPUT.put_line(222222);
end if;
exception
when NO_DATA_FOUND then
DBMS_OUTPUT.put_line(3333333);
end;




-- for update
select * from productlang a for update of productlangid

select * from productlang a for update
select * from productlang a for update nowait
select * from productlang a for update wait 10


declare
cursor c_allproduct is
select * from product
for update;--for update不能在@环中使用commit
v_oneprd c_allproduct%rowtype;
begin
open c_allproduct;
fetch c_allproduct into v_oneprd;
commit;--for update不能在@环中使用commit
fetch c_allproduct into v_oneprd;
end;


declare
cursor c_allproduct is
select * from product ;

v_oneprd c_allproduct%rowtype;
begin
open c_allproduct;

loop
fetch c_allproduct into v_oneprd;
exit when c_allproduct%notfound;
commit;


end loop;
close c_allproduct;
--close c_allproduct;-- INVALID_CURSOR
end;


declare
type t_ddd is ref cursor return product%rowtype;
v_CursorVar t_ddd;
begin
open v_CursorVar for select * from
organization;--cd与游标变量返回类型不?br> close v_CursorVar;
end;


--错误处理--------------------------------------------------------------------------
declare v_NumStudents number;
begin
select count(1)
into v_NumStudents
from sstudents;--~译错误
end;



declare
x number:=1;
y number:=2;
z number:=3;
begin
y:=x/0;--q行时异?br>exception
when others then
dbms_output.put_line(sqlcode||sqlerrm);
end;


declare
type t_NumberTableType is table of number
index by binary_integer;
v_NumberTable t_NumberTableType;
v_temp number;
begin
v_temp:=v_NumberTable(1);--NO_DATA_FOUND
end;

DECLARE
v_TempVar varchar2(2);
begin
v_TempVar:='111';--NUMERIC OR VALUE ERROR
end;


declare
e_TooManyStudents exception;--自定义异?br> v_currentStudents number(4);
v_Max number(4);
begin

select 10,count(1) into v_Max,v_currentStudents from product ;
if v_Max<v_currentStudents then
raise e_TooManyStudents;
end if;
exception
when e_TooManyStudents then
dbms_output.put_line(sqlcode||' '||sqlerrm);

end;

--7.1.3
declare
v_xxx varchar2(200);
begin
v_xxx :=sqlerrm(1);
dbms_output.put_line('sqlerrm: '''||sqlerrm||'''');
dbms_output.put_line('sqlerrm(0): '''||sqlerrm(0)||'''');
dbms_output.put_line('sqlerrm(100): '''||sqlerrm(100)||'''');
dbms_output.put_line('sqlerrm(-1): '''||sqlerrm(-1)||'''');
dbms_output.put_line('sqlerrm(-54): '''||sqlerrm(-54)||'''');
dbms_output.put_line('sqlerrm(10): '''||sqlerrm(10)||'''');
end;

--7.1.4
declare
e_missingNull exception;
pragma exception_init(e_missingNull,-1400); --~译指示
begin
insert into dictionary(dictionaryid) values(null);
exception
when e_missingNull then
dbms_output.put_line(sqlcode||' '||sqlerrm);--不显C?user-defined
exception"
end;


--7.1.5

declare
e_TooManyStudents exception;--自定义异?br> v_currentStudents number(4);
v_Max number(4);
begin

select 10,count(1) into v_Max,v_currentStudents from product ;
if v_Max<v_currentStudents then
--raise e_TooManyStudents;
raise_application_error(-20001,'long long ago there was an
idiot!');
end if;
exception
when others then
dbms_output.put_line(sqlcode||' '||sqlerrm);
--delete jjl;
--commit;
--raise;

end;

begin
declare
e_TooManyStudents exception;--自定义异?br> begin
raise e_TooManyStudents;
end;
exception
when e_TooManyStudents then --自定义异常超Z用域
raise;
end;


declare
v_Tmp number(6):='ABC';--声明中的错误直接传到最外层
begin
null;--begin后面一定要有东?br> exception
when others then
dbms_output.put_line(sqlcode||' '||sqlerrm);
end;


begin
declare
v_Tmp number(6):='ABC';--声明中的错误直接传到最外层
begin
null;--begin后面一定要有东?br> exception
when others then
dbms_output.put_line('2222');
end;
exception
when others then
dbms_output.put_line(sqlcode||' '||sqlerrm);
end;





--集合--------------------------------------------------------------------------------
declare
type NumberTab is table of number index by binary_integer;
v_Numbers NumberTab;
begin
for v_Count in 1..10 loop
v_Numbers(v_Count):=v_Count;
end loop;

for v_Count in 1..10 loop
dbms_output.put_line('number['||to_char(v_count)||']='||'
'||v_Numbers(v_Count));
end loop;

dbms_output.put_line('number['||to_char(11)||']='||'
'||v_Numbers(11));

exception
when no_data_found then
dbms_output.put_line(sqlcode||' '||sqlerrm);
end;




declare
type ProdTab is table of product%rowtype index by binary_integer;
v_Prods ProdTab;
begin
if v_Prods is null then
dbms_output.put_line('v_Prods is null');
end if;
select *
into v_Prods(2000001160)
from product
where prodid=2000001160;

dbms_output.put_line('the code of prod['||to_char(2000001160)||']='||'
'||v_Prods(2000001160).prodcode);

exception
when no_data_found then
dbms_output.put_line(sqlcode||' '||sqlerrm);
end;

--嵌套表构造器初始?br>declare
type NumberTab is table of number;
v_Tab1 NumberTab:=NumberTab();
v_Tab2 NumberTab:=NumberTab(2);
v_Tab3 NumberTab;
begin
if v_Tab1 is null then
dbms_output.put_line('v_Tab1 is Null');
else
dbms_output.put_line('v_Tab1 is not Null');
end if;
--v_Tab1(1):=1;--wrong 元素不存? subscript beyond count
if v_Tab2 is null then
dbms_output.put_line('v_Tab2 is Null');
else
dbms_output.put_line('v_Tab2 is not Null ' || v_Tab2(1));
end if;

if v_Tab3 is null then
dbms_output.put_line('v_Tab3 is Null');
else
dbms_output.put_line('v_Tab3 is not Null');
end if;
end;



declare
type Numbers is array(20) of number(3);--可变数组

v_NullList Numbers;
v_List1 Numbers:=Numbers(1,2);--数组大小由构造器军_
v_List2 Numbers:=Numbers(null);
begin
if v_NullList is null then
dbms_output.put_line('v_NullList is Null');
end if;

if v_List1(1) is null then
dbms_output.put_line('v_List1(1) is Null');
end if;

if v_List2(1) is null then
dbms_output.put_line('v_List2(1) is Null');
end if;

--v_List1(3):=1;-- subscript beyond count 数组大小由构造器军_
v_List1.extend;
v_List1(3):=1;

end;



--多层集合
declare
type t_Numbers is table of number index by binary_integer;
type t_MultiNumbers is table of t_Numbers index by binary_integer;

type t_MultiArray is varray(10) of t_Numbers;
type t_MultiNested is table of t_Numbers;

v_MultiNumbers t_MultiNumbers;
begin
v_MultiNumbers(1)(1):=1;
end;



-- q程Q函敎ͼ?br>create or replace procedure ModeTest(p_InParam in number,p_OutParam out
number
,p_InOutParam in out number)is
v_localVariable number :=0;
begin
dbms_output.put_line('Inside ModeTest');
if(p_InParam is null) then
dbms_output.put_line('p_InParam is null');
else
dbms_output.put_line('p_InParam is '||p_InParam);
end if;

if(p_OutParam is null) then
dbms_output.put_line('p_OutParam is null');
else
dbms_output.put_line('p_OutParam is '||p_OutParam);
end if;

if(p_InOutParam is null) then
dbms_output.put_line('p_InOutParam is null');
else
dbms_output.put_line('p_InOutParam is '||p_InOutParam);
end if;

v_localVariable := p_InParam; --legal
--p_InParam:=7;--illegal
p_OutParam:=7;
v_localVariable:=p_OutParam;--possibly illegal,illegal prior to
7.3.4
v_localVariable:=p_InOutParam;
p_InOutParam:=8;

dbms_output.put_line('at the end of ModeTest');
if(p_InParam is null) then
dbms_output.put_line('p_InParam is null');
else
dbms_output.put_line('p_InParam is '||p_InParam);
end if;

if(p_OutParam is null) then
dbms_output.put_line('p_OutParam is null');
else
dbms_output.put_line('p_OutParam is '||p_OutParam);
end if;

if(p_InOutParam is null) then
dbms_output.put_line('p_InOutParam is null');
else
dbms_output.put_line('p_InOutParam is '||p_InOutParam);
end if;

end ModeTest;

declare
v_a number :=1;
v_b number :=2;
begin
ModeTest(1,v_a,v_b);
end;

drop procedure ModeTest;

-----------------------

create or replace procedure ParamLength(p_param1 in out varchar2,
p_param2 in out number)is
begin
p_param1:='abcdefghijklmno';
p_param2:=12.3;
end;

declare
v_a varchar(40);
--v_a varchar(10);--形参U束从实际参数获?br> v_b number(7,3);
begin
ParamLength(v_a,v_b);
end;

drop procedure ParamLength;
-------------------------

create or replace procedure RaiseError(
p_Raise in boolean,
p_ParamA out number)as
begin
p_ParamA:=7;

if p_Raise then
raise dup_val_on_index;--当存储过E发生错误时,out
inout形式参数g会返回给实际参数
else
return;
end if;
end RaiseError;


create or replace procedure RaiseError(
p_Raise in boolean,
p_ParamA out nocopy number)as--传引?即报错,g会被修改
begin
p_ParamA:=7;

if p_Raise then
raise dup_val_on_index;
else
return;
end if;
end RaiseError;


declare v_tmp number:=1;
--declare v_tmp number(2):=1;--实际参数受精度可Lnot
nullU束Qnocopy无效
begin
dbms_output.put_line('initial value: '||v_tmp);
raiseError(false,v_tmp);
dbms_output.put_line('after false: '||v_tmp);
v_tmp:=2;
dbms_output.put_line('before true: '||v_tmp);
raiseError(true,v_tmp);

exception
when others then
dbms_output.put_line('after unsuccessful: '||v_tmp);
end;

drop procedure RaiseError;

------------------------------
create or replace procedure DefaultTest(
p_ParameterA number default 10,
p_ParameterB varchar2 default 'abcdef',
p_ParameterC date default sysdate)as
begin
dbms_output.put_line(
'A: '|| p_ParameterA||
' B: '||p_ParameterB||
'C:'||to_char(p_ParameterC,'DD-MON-YYYY')
);
end;

begin
DefaultTest(p_ParameterA=>7,p_ParameterC =>
to_date('30-11-2005','DD-MM-YYYY'));
end;--命名W?br>
begin
DefaultTest(7);--定位W?br>end;




--9.1.3 call语句
call DefaultTest(10);
call DefaultTest();

begin
--call DefaultTest();
execute immediate 'call DefaultTest()';
end;



drop procedure DefaultTest;


------------------------------------
create or replace function CallFunc(p1 in varchar2)
return varchar2 as
begin
dbms_output.put_line('callfunc called with '||p1);
return p1;
end;


declare
v_Result varchar2(50);
begin
execute immediate
'call CallFunc(''hello from pl/sql'')into :v_Result '
using out v_Result;
end;

drop function CallFunc;


---------------------------------------
create or replace package packA as
procedure xxxx1(p_var1 in number);
end packA;
create or replace package body packA as
procedure xxxx2(p_var1 in number) is
begin
dbms_output.put_line('xxxx2 '||p_var1);
end;--xxxx2必须在xxxx1之前Qxxxx1才能调用到xxxx2

procedure xxxx1(p_var1 in number) is
begin
dbms_output.put_line('xxxx1 '||p_var1);
dbms_output.put_line('xxxx1 call xxxx2');
xxxx2(2);
end;

end packA;



begin
packA.xxxx1(1);
--packA.xxxx2(1);--not visible from outside
end;

drop package packA;



-------------------------------------------------------------------
--chapter 10
--10.1.1
create or replace procedure Simple as
v_Counter number;
begin
v_Counter:=7;
end Simple;

select *
from user_objects
where object_name='SIMPLE'--存储在数据字怸的都是大?br>
select *
from user_source--源代?br>where name='SIMPLE' order by line


create or replace procedure Simple as
v_Counter number;
begin
v_Counter:=7--;
end Simple;


select *
from user_errors
where name='SIMPLE'

begin
Simple;
end;
drop procedure Simple;

--------------------------------
--10.1.2
create or replace procedure Simple as

v_Counter number;

function formatName(p_FirstName in varchar2,p_LastName in
varchar2)--只能攑֜声明最?br> return varchar2 is
begin
dbms_output.put_line(p_FirstName||' '||p_LastName);
end formatName;
begin
v_Counter:=7;
end Simple;


create or replace procedure Simple2 as
procedure BBB;--预先声明
procedure AAA is
begin
BBB;
end AAA;

procedure BBB is
begin
AAA;
end BBB;

begin
null;
end Simple2;





------------------------------------------------------------------------------------------
begin
dbms_shared_pool.sizes(1);
end;



-------------------------------------------------------------------------------------------
--charter 12
--l定变量
declare
v_Type dictionary.type%type;
v_Name dictionary.valuename%type;
v_Sql varchar(200);
begin
v_Type:='Status';
v_Sql := 'select valuename from dictionary where rownum=1 and
type=:type and languagecode=''cn''';
execute immediate v_Sql into v_Name using v_Type;
dbms_output.put_line(v_Name);



end;



--集体l定
declare
type t_Table is table of varchar(20) index by binary_integer;
v_Table t_Table;
begin
for v_Count in 1..100 loop
v_Table(v_Count):=to_char(v_Count);
end loop;

forall v_Count in 1..100
insert into jjl values(v_Table(v_Count));
dbms_output.put_line(sql%rowcount);
commit;
forall v_Count in 1..100
delete jjl where a1=(v_Table(v_Count));
dbms_output.put_line(sql%rowcount);
commit;
end;

select * from jjl

--bulk collect

declare
type t_Table is table of jjl.a1%type index by binary_integer;
v_Table t_Table;
v_var jjl.a1%type;
begin
select a1
bulk collect into v_Table
from jjl;
--for v_count in 1..v_Table.count loop
dbms_output.put_line(v_Table.count);
-- end loop;

for v_count in 1..6 loop
dbms_output.put_line(substr(v_Table(v_count)));
end loop;
end;












declare
v_xxx number(10):=1;
begin
dbms_output.put_line('v_xxx is '||v_xxx);
v_xxx:=null;
dbms_output.put_line('v_xxx is '||to_char(v_xxx));
end;



declare
type t_cur is ref cursor;
v_cur t_cur;
v_usr usr%rowtype;
v_sql varchar2(100):='select userid,username from usr';
v_userid usr.userid%type;
v_username usr.username%type;
--'select userid,username from usr' 报错数量不一?br>begin
open v_cur for v_sql;
loop
fetch v_cur into v_userid,v_username;
exit when v_cur%notfound;
dbms_output.put_line(to_char(v_userid));
end loop;
close v_cur;

end;


select instr('aaa','b') from dual
declare
v_str varchar2(1000):='aaa,bbb,ccc,ddd,eee,fff';
v_tmpstr varchar2(1000);
v_dest varchar2(1000);
begin
v_str := ''''||v_str||'''';
v_str := replace(v_str,',',''',''');
dbms_output.put_line(v_str);
end;



create or replace function xjp3addquote(p_str in varchar2) return
varchar2 as
v_desc varchar2(2000);
begin
v_desc := ''''||p_str||'''';
v_desc := replace(v_desc,',',''',''');
return v_desc;
end;


declare
v_aa number(3):=2;
v_bb number(3):=0;
v_cc number(4,2);
begin
v_cc := v_aa/v_bb;

--dbms_output.put_line(substr(sqlerrm,1,128));
end;


妖h 2007-08-23 12:31 发表评论
]]>
临时表temporary tablehttp://www.aygfsteel.com/shypwang/articles/138781.html妖h妖hThu, 23 Aug 2007 04:15:00 GMThttp://www.aygfsteel.com/shypwang/articles/138781.htmlhttp://www.aygfsteel.com/shypwang/comments/138781.htmlhttp://www.aygfsteel.com/shypwang/articles/138781.html#Feedback0http://www.aygfsteel.com/shypwang/comments/commentRss/138781.htmlhttp://www.aygfsteel.com/shypwang/services/trackbacks/138781.html 临时表temporary table
===========================================================
a
8i以上版本?br> Oracle 的(f)时表与MSSQL的不同,临时表需要先创徏Q不在运行时使用DDL语句创徏Q?br> 临时表可以看作是一张普通的物理表,在其上可以徏索引、徏视图Q徏触发器等Q但它的数据是会话隔ȝ?br> 区别之处:
l 向表中插入数据只在会话或事务期间存在
l 表中的数据只Ҏ(gu)入数据的会话是可见的
l 可用ON COMMIT指导定数据是会话专用q是事务专用
临时表的限定:
l 临时表不能被分区
l 不能指定U束
l 不包括含嵌套表的列或VARRAYcd
l 不能指定TABLESPACE, STORAGE_CLAUSE, LONGGING, NOLOGGING, MONITORING, LOB_INDEX_CLAUSE{?br> l 不能指定SEGMENT_ATTRIBUTES_CLAUSE,NESTED_TABLE_COL_PROPERTIES或PARALLEL_CLAUSE
l 分布事务不支持(f)时表

临时表的创徏Q?br> create global temporary tablename(column list) 
on commit preserve rows; --提交保留数据 会话临时?nbsp;
on commit delete rows; --提交删除数据 事务临时?nbsp;
临时表是相对于会话的Q别的会话看不到该会话的数据?br> oracle的(f)时表和sql server不一P在用完成以后,oracle临时表中的纪录可以被定义动删除(分session方式和transaction方式Q,而表l构不会被自动删除;sql server中的临时表在使用后会被完全删除?br> 所以,如果是常用的临时表,你不妨一开始就建好表?br> 在用的时候,不同对话之间的纪录互怸q扰Q所以不会给使用带来M问题?br>
对偶用的临时表,也可以在q程中用动态SQL来徏立(但不QDDL语句有较大的开销Q)Q?br> CREATE OR REPLACE PROCEDURE myProc(...) AUTHID current_user IS
...
BEGIN
EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY ....';
...
END;
Q?br> 不得已的情况下(比较复杂的数据处理)才用(f)时表Q否则尽可能使用子查询代替或使用游标?


妖h 2007-08-23 12:15 发表评论
]]>
oracle临时?/title><link>http://www.aygfsteel.com/shypwang/articles/138773.html</link><dc:creator>妖h</dc:creator><author>妖h</author><pubDate>Thu, 23 Aug 2007 03:53:00 GMT</pubDate><guid>http://www.aygfsteel.com/shypwang/articles/138773.html</guid><wfw:comment>http://www.aygfsteel.com/shypwang/comments/138773.html</wfw:comment><comments>http://www.aygfsteel.com/shypwang/articles/138773.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/shypwang/comments/commentRss/138773.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/shypwang/services/trackbacks/138773.html</trackback:ping><description><![CDATA[<div id="wmqeeuq" class="postTitle"> <a href="http://www.aygfsteel.com/pdw2009/archive/2007/06/20/125383.html" id="viewpost1_TitleUrl" class="postTitle2">oracle临时?/a> </div> 在Oracle8i或以上版本中Q可以创Z下两U(f)时表Q?<br>1。会话特有的临时?<br>    CREATE GLOBAL TEMPORARY <TABLE_NAME> (<column specification>) <br>    ON COMMIT PRESERVE ROWSQ?<br>  <br>2。事务特有的临时?<br>    CREATE GLOBAL TEMPORARY <TABLE_NAME> (<column specification>) <br>    ON COMMIT DELETE ROWSQ?<br>   CREATE GLOBAL TEMPORARY TABLE MyTempTable <br>所建的临时表虽然是存在的,但是你试一下insert 一条记录然后用别的q接M去selectQ记录是I的Q明白了吧,我把下面两句话再贴一下: <br>--ON COMMIT DELETE ROWS 说明临时表是事务指定Q每ơ提交后ORACLE截断表Q删除全部行Q?<br>--ON COMMIT PRESERVE ROWS 说明临时表是会话指定Q当中断会话时ORACLE截断表?<br>冲突的问题更本不用考虑. <br>  <br>临时表只是保存当前会?session)用到的数据,数据只在事务或会话期间存在?<br>  <br>通过CREATE GLOBAL TEMPORARY TABLE命o创徏一个(f)时表Q对于事务类型的临时表, <br>数据只是在事务期间存在,对于会话cd的(f)时表Q数据在会话期间存在?<br>  <br>会话的数据对于当前会话私有。每个会话只能看到ƈ修改自己的数据。DML锁不会加?<br>临时表的数据上。下面的语句控制行的存在性?<br>   <br>?ON COMMIT DELETE ROWS 表名行只是在事务期间可见 <br>?ON COMMIT PRESERVE ROWS 表名行在整个会话期间可见 <br>  <br>可以对(f)时表创徏索引Q视图,出发器,可以用export和import工具导入导出表的 <br>定义Q但是不能导出数据。表的定义对所有的会话可见?br><br><br>Temporary Tables临时?br>1?br>   ORACLE数据库除了可以保存永久表外,q可以徏立(f)时表temporary tables。这些(f)时表用来保存一个会话SESSION的数据,<br>   或者保存在一个事务中需要的数据。当会话退出或者用h交commit和回滚rollback事务的时候,临时表的数据自动清空Q?br>   但是临时表的l构以及元数据还存储在用L(fng)数据字典中?br>   临时表只在oracle8i以及以上产品中支持?br>2详细介绍<br>   Oracle临时表分?会话U(f)时表 ?事务U(f)时表?br>会话U(f)时表是指临时表中的数据只在会话生命周期之中存在,当用户退Z话结束的时候,Oracle自动清除临时表中数据?br>事务U(f)时表是指临时表中的数据只在事务生命周期中存在。当一个事务结束(commit or rollbackQ,Oracle自动清除临时表中数据?br>临时表中的数据只对当前Session有效Q每个Session都有自己的(f)时数据,q且不能讉K其它Session的(f)时表中的数据。因此,<br>临时表不需要DML?当一个会话结?用户正常退?用户不正帔R?ORACLE实例崩溃)或者一个事务结束的时候,Oracle对这个会话的<br>表执?TRUNCATE 语句清空临时表数?但不会清I其它会话(f)时表中的数据.<br>你可以烦引(f)时表和在临时表基上徏立视?同样,建立在(f)时表上的索引也是临时?也是只对当前会话或者事务有?  <br>临时表可以拥有触发器.<br>3建立临时?br>   临时表的定义Ҏ(gu)有会话SESSION都是可见?但是表中的数据只对当前的会话或者事务有? <br>   建立Ҏ(gu):<br>1) ON COMMIT DELETE ROWS 定义了徏立事务临时表的Ҏ(gu).<br>CREATE GLOBAL TEMPORARY TABLE admin_work_area<br>        (startdate DATE,<br>         enddate DATE,<br>         class CHAR(20))<br>      ON COMMIT DELETE ROWS;<br>EXAMPLE:<br>SQL> CREATE GLOBAL TEMPORARY TABLE admin_work_area<br>  2          (startdate DATE,<br>  3           enddate DATE,<br>  4           class CHAR(20))<br>  5        ON COMMIT DELETE ROWS;<br>SQL> create table permernate( a number);<br>SQL> insert into admin_work_area values(sysdate,sysdate,'temperary table');<br>SQL> insert into permernate values(1);<br>SQL> commit;<br>SQL> select * from admin_work_area;<br>SQL> select  * from permernate;<br>A<br>1<br>2)ON COMMIT PRESERVE ROWS 定义了创Z话临时表的Ҏ(gu).<br>CREATE GLOBAL TEMPORARY TABLE admin_work_area<br>        (startdate DATE,<br>         enddate DATE,<br>         class CHAR(20))<br>     ON COMMIT PRESERVE ROWS;<br>EXAMPLE:<br><br>会话1:<br>SQL> drop table admin_work_area;<br>SQL> CREATE GLOBAL TEMPORARY TABLE admin_work_area<br>  2          (startdate DATE,<br>  3           enddate DATE,<br>  4           class CHAR(20))<br>  5       ON COMMIT PRESERVE ROWS;<br>SQL> insert into permernate values(2);<br>SQL> insert into admin_work_area values(sysdate,sysdate,'session temperary');<br>SQL> commit;<br>SQL> select * from permernate;<br><br>         A<br>----------<br>         1<br>         2<br><br>SQL> select * from admin_work_area;<br><br>STARTDATE  ENDDATE    CLASS<br>---------- ---------- --------------------<br>17-1?? -03 17-1?? -03 session temperary<br><br>会话2:<br><br>SQL> select * from permernate;<br><br>         A<br>----------<br>         1<br>         2<br><br>SQL> select * from admin_work_area;<br><br>未选择?<br><br>会话2看不见会?中(f)时表的数?<img src ="http://www.aygfsteel.com/shypwang/aggbug/138773.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/shypwang/" target="_blank">妖h</a> 2007-08-23 11:53 <a href="http://www.aygfsteel.com/shypwang/articles/138773.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank">差</a>| <a href="http://" target="_blank">ߺ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ϻӿ</a>| <a href="http://" target="_blank">ƴ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ԫ</a>| <a href="http://" target="_blank">IJ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">差</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">¹Ȫ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Դ</a>| <a href="http://" target="_blank">ƴ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">˶</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ԭ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ٹ</a>| <a href="http://" target="_blank">¸</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">˳</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ˮ</a>| <a href="http://" target="_blank">Ƕ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>