??xml version="1.0" encoding="utf-8" standalone="yes"?>一区二区在线观看av,精品国产乱码久久久久久88av,欧美精品在线免费观看http://www.aygfsteel.com/improviser/category/26128.html思维是一U艺术,艺术需要灵?/description>zh-cnSun, 04 Nov 2007 18:54:44 GMTSun, 04 Nov 2007 18:54:44 GMT60Oracle之函C触发?/title><link>http://www.aygfsteel.com/improviser/archive/2007/10/05/150456.html</link><dc:creator>improviser</dc:creator><author>improviser</author><pubDate>Thu, 04 Oct 2007 16:04:00 GMT</pubDate><guid>http://www.aygfsteel.com/improviser/archive/2007/10/05/150456.html</guid><wfw:comment>http://www.aygfsteel.com/improviser/comments/150456.html</wfw:comment><comments>http://www.aygfsteel.com/improviser/archive/2007/10/05/150456.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.aygfsteel.com/improviser/comments/commentRss/150456.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/improviser/services/trackbacks/150456.html</trackback:ping><description><![CDATA[   <font color="#000080" size="4"> 今天写有关Oracle中函C触发器的内容Q在数据库中定义q用存储过E、函数、触发器Q可以提高用戯问数据库的效率?br /><br />    数据库中函数包含四个部分Q?b>声明、返回倹{函C和异常处?/b>?/font><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 255);">create</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">or</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">replace</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> getname(sno </span><span style="color: rgb(0, 0, 0); font-weight: bold;">varchar2</span><span style="color: rgb(0, 0, 0);">)<br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0); font-weight: bold;">varchar</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">is</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);">        name </span><span style="color: rgb(0, 0, 0); font-weight: bold;">varchar</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(128, 0, 0); font-weight: bold;">12</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">begin</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">select</span><span style="color: rgb(0, 0, 0);"> ename </span><span style="color: rgb(0, 0, 255);">into</span><span style="color: rgb(0, 0, 0);"> name </span><span style="color: rgb(0, 0, 255);">from</span><span style="color: rgb(0, 0, 0);"> emp </span><span style="color: rgb(0, 0, 255);">where</span><span style="color: rgb(0, 0, 0);"> empno</span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);">sno;<br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> name;<br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);"> exception<br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">       ...</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">end</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);"></span></div><br />   <font color="#000080"></font><font size="4"><font color="#000080">触发器是一U特D的存储q程Q类g其它~程语言中的事g函数Q允ؓ INSERT、UPDATE、DELETE 创徏触发器,当在表(视图Q中插入、更新、删除记?前、后)Ӟ触发一个或一pd T-SQL 语句?/font><span style="font-family: 宋体; color: blue;"><br /><br />    创徏?/span><span style="color: blue;" lang="EN-US">STUDENT</span><span style="font-family: 宋体; color: blue;">表上的插入触发器Q当?/span><span style="color: blue;" lang="EN-US">STUDENT</span><span style="font-family: 宋体; color: blue;">表中插入数据时候触发器被触发Q执行体被执行</span></font><span style="color: blue;" lang="EN-US"><o:p></o:p></span><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);">   插入触发?br /> 1</span> <span style="color: rgb(0, 0, 255);">create</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">or</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">replace</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">trigger</span><span style="color: rgb(0, 0, 0);"> tg_insert<br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);"> before </span><span style="color: rgb(0, 0, 255);">insert</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">on</span><span style="color: rgb(0, 0, 0);"> student                </span><span style="color: rgb(128, 128, 128);">Q-</span><span style="color: rgb(0, 0, 0);">可设|在插入前或插入?br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">begin</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);">       ...</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">end</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);"> <br /><br /></span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 128, 128);">   </span><span style="color: rgb(0, 0, 0);">更新触发?br /></span><span style="color: rgb(0, 128, 128);"> 8</span>  <span style="color: rgb(0, 0, 255);">create</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">or</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">replace</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">trigger</span><span style="color: rgb(0, 0, 0);"> tg_update<br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);"> after </span><span style="color: rgb(0, 0, 255);">update</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">on</span><span style="color: rgb(0, 0, 0);"> student<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> each row </span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">begin</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);">     ...</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">END</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 0, 0);"></span></div><br /><p class="MsoNormal" style="margin-left: 21pt;"><font size="4"><b style=""><span style="font-family: 宋体; color: blue;">触发器两个特D行U变量:</span><span style="color: red;" lang="EN-US"> :New</span></b><b style=""><span style="font-family: 宋体; color: blue;">新?/span><span style="color: blue;" lang="EN-US"><span style="">  </span></span></b><b style=""><span style="font-family: 宋体; color: blue;">?/span><span style="color: blue;" lang="EN-US"><span style="">  </span></span><span style="color: red;" lang="EN-US">:Old</span></b><b style=""><span style="font-family: 宋体; color: blue;">旧?/span><span style="color: blue;" lang="EN-US"><span style="">  </span></span></b><b style=""><span style="font-family: 宋体; color: blue;">分别代表更新|被更新的?/span></b></font></p><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 255);">create</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">or</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">replace</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">trigger</span><span style="color: rgb(0, 0, 0);"> tg_insert<br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);">after </span><span style="color: rgb(0, 0, 255);">update</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">on</span><span style="color: rgb(0, 0, 0);"> student<br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> each row<br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">when</span><span style="color: rgb(0, 0, 0);"> (:old.sex</span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);">’j?        Q-</span><span style="color: rgb(128, 128, 128);"></span><span style="color: rgb(0, 0, 0);">当old.sex为J时候才执行触发器内?br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">begin</span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 128, 128);"></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">   DBMS_OUTPUT.PUT_LINE(:new.stuname</span><span style="color: rgb(128, 128, 128);">||</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">  </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(128, 128, 128);">||</span><span style="color: rgb(0, 0, 0);">:old.stuname);<br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">   DBMS_OUTPUT.PUT_LINE(:new.sex</span><span style="color: rgb(128, 128, 128);">||</span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(255, 0, 0);">  </span><span style="color: rgb(255, 0, 0);">'</span><span style="color: rgb(128, 128, 128);">||</span><span style="color: rgb(0, 0, 0);">:old.sex);<br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">end</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);"></span></div><br /><p class="MsoNormal" style="margin-left: 21pt;"><font size="4"><b style=""><span style="font-family: 宋体; color: blue;">判断复合型触发器</span></b></font></p><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 255);">create</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">or</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 255);">replace</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">trigger</span><span style="color: rgb(0, 0, 0);"> trgstudeng<br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);">before </span><span style="color: rgb(0, 0, 255);">insert</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">or</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">update</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 128, 128);">or</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">delete</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">on</span><span style="color: rgb(0, 0, 0);"> student<br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> each row<br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">begin</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">  inserting </span><span style="color: rgb(0, 0, 255);">then</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);">    ...</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">end</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> deleting </span><span style="color: rgb(0, 0, 255);">then</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">    ...</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">end</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);">exception<br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);">    ...</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">16</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">END</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">17</span> <span style="color: rgb(0, 0, 0);"></span></div><br /> <font color="#000080" size="4">  触发器功能强大,可以实现许多复杂的功能,但如果滥用会造成数据库及应用E序的维护困难?br /><br /></font><font color="#000080" size="4">  (<font color="#ff0000">转蝲h明出?/font>)  </font><br /><img src ="http://www.aygfsteel.com/improviser/aggbug/150456.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/improviser/" target="_blank">improviser</a> 2007-10-05 00:04 <a href="http://www.aygfsteel.com/improviser/archive/2007/10/05/150456.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oracle存储q程http://www.aygfsteel.com/improviser/archive/2007/10/03/150224.htmlimproviserimproviserTue, 02 Oct 2007 16:07:00 GMThttp://www.aygfsteel.com/improviser/archive/2007/10/03/150224.htmlhttp://www.aygfsteel.com/improviser/comments/150224.htmlhttp://www.aygfsteel.com/improviser/archive/2007/10/03/150224.html#Feedback2http://www.aygfsteel.com/improviser/comments/commentRss/150224.htmlhttp://www.aygfsteel.com/improviser/services/trackbacks/150224.html 存储q程 包含三部分: 声明Q执行部分,异常?/span>

可以有无参数E序和带参数存储q程?/font>

无参E序语法

1 create or replace procedure NoParPro
2 as  ;
3 begin
4 ;
5 exception
6     ;
7 end;
8 

   带参存储q程实例

 1 create or replace procedure queryempname(sfindno emp.empno%type) as
 2        sName emp.ename%type;
 3        sjob emp.job%type;
 4 begin
 5        ....
 7 exception
          ....
14 end;
15 

   带参数存储过E含赋值方?/font>
 1 create or replace procedure runbyparmeters  (isal in emp.sal%type,
                            sname out 
varchar,sjob in out varchar)
 2  as icount number;
 3  begin
 4       select count(*into icount from emp where sal>isal and job=sjob;
 5       if icount=1 then
 6         ....
 9       else
10         ....
12       end if;
13  exception
14       when too_many_rows then
15       DBMS_OUTPUT.PUT_LINE('q回值多??/span>');
16       when others then
17       DBMS_OUTPUT.PUT_LINE('在RUNBYPARMETERSq程中出错!');
18  end;
19 

  q程调用
 
方式一
 1 declare
 2        realsal emp.sal%type;
 3        realname varchar(40);
 4        realjob varchar(40);
 5  begin
 6        realsal:=1100;
 7        realname:='';
 8        realjob:='CLERK';
 9        runbyparmeters(realsal,realname,realjob);     Q-必须按顺?br />10        DBMS_OUTPUT.PUT_LINE(REALNAME||'   '||REALJOB);
11  END;
12 

  方式?/font>
 1 declare
 2       realsal emp.sal%type;
 3       realname varchar(40);
 4       realjob varchar(40);
 5 begin
 6       realsal:=1100;
 7       realname:='';
 8       realjob:='CLERK';
 9       runbyparmeters(sname=>realname,isal=>realsal,sjob=>realjob);  Q-指定值对应变量顺序可?br />10       DBMS_OUTPUT.PUT_LINE(REALNAME||'   '||REALJOB);
11 END;
12 

 


improviser 2007-10-03 00:07 发表评论
]]>
Oracle中的OOPhttp://www.aygfsteel.com/improviser/archive/2007/10/02/150166.htmlimproviserimproviserTue, 02 Oct 2007 03:44:00 GMThttp://www.aygfsteel.com/improviser/archive/2007/10/02/150166.htmlhttp://www.aygfsteel.com/improviser/comments/150166.htmlhttp://www.aygfsteel.com/improviser/archive/2007/10/02/150166.html#Feedback0http://www.aygfsteel.com/improviser/comments/commentRss/150166.htmlhttp://www.aygfsteel.com/improviser/services/trackbacks/150166.html     关系数据库在不断地发展时Q许多数据库引入了面向对象的思想Q这其中以OracleZ表,Oracle9i号U面向对象数据库?/font> 自Oracle9i以来QOracle׃再是单纯的关pL据库理pȝQ它在关pL据库模型的基上,d了一pd面向对象的特性。Oracle的对象体p遵从面向对象思想的基本特征,许多概念同C++,JAVA中类|hl承Q重载,多态等特征Q但又有自己的特炏V?br />
1?/span>
Oracle面向对象的最基本元素是它的对象类型—?b>Type?br />下面开始写自定义对象类? as object 必须关键?
1 create or replace type ADDRESS as object
2 (
3      PROVINCE varchar(10),
4      CITY varchar(20),
5      STREET varchar(30)
6 );

创徏表ƈ使用以上对象cdADDRESS
1 create table STUDENTOBJ 
2 (
3     STUNAME varchar(20),
4     STUADD  ADDRESS
5 );
6 
7 向表中插入数据:
8 insert into STUDENTOBJ values('improviser',ADDRESS('q东?/span>','q州?/span>'Q?/span>'江v大道');

通过别名对表q行查询
1 select S.STUNAME S.ADDRESS.PROVINCE S.ADDRESS.CITY
2 S.ADDRESS.STREET 
from STUDENTOBJ S;

从上面的试代码Q可以很Ҏ看到其与面向对象语言Q比如JavaQ的差异Q不必用new创徏实例Q也没有了默认无参数构造器Q默认用定义的属性作为构造器参数Q以描q各U实体。另外,Type的属性没有private,protected,public的说法,所有的属性调用者都可以讉KQ即都是public?br />
2、Oracle中面向对象特征—?b>l承(父类型必d明ؓNOT FINAL,子类型用关键字UNDER)

 1 创徏父类?br /> 2 create or replace type PERSON as object
 3 (
 4     PERNAME varchar(10),
 5     PERSEX varchar(2)
 6 )not final;
 7 
 8 子类型承父cd
 9 create or replace type STUDENT under PERSON
10 (
11     STUNO varchar(8),
12     STUSCORE varchar(10)
13 );

׃上定义,其子cd中属性包含了父类型中所有属性?br />

3、可变数l?/b>
可变数组Q是一U集合。一个可变数l是对象的一个集合,其中每个对象都具有相同的数据cd。可变数l的大小由创建时军_。在表中建立可变数组后,可变数组在主表中作ؓ一个列对待?/font>
 1 创徏对象cd
 2 create or replace type ADDRESS as object
 3 (
 4     PROVINCE varchar(10),
 5     CITY varchar(20),
 6 );
 7 
 8 创徏ADDRESS可变数组
 9 create or replace type ADDRESS_LIST as varray(3of ADDRESS;
10 
11 创徏表ƈ使用可变数组ADDRESS_LIST
12 create table STUDENT 
13 (
14     STUNAME varchar(20),
15     STUADDS ADDRESS_LIST
16 );
17 
18 向表中插入数?br />19 insert into STUDENT values('improviser',ADDRESS_LIST(ADDRESS('q东?/span>','q州?/span>','江v大道'),
                                           ADDRESS(
'q东?/span>','潮州?/span>','潮枫?/span>')));
20 
21 查询(使用table函数数据表格Ş式输?
22 select *from table(select s.STUADDS from STUDENT where STUNAME='improviser');

4、嵌套表
嵌套表是表中之表Q一个嵌套表是某些行的集合,它在主表中表CZؓ其中的一列。对主表中的每一条记录,嵌套表可以包含多个行?/font>
 1 定义嵌套表方法:
 2 create or replace type ADDRESS_TABLE as table of ADDRESS;
 3 
 4 基本对象cd、创、查询和插入数据都跟上面可变数组一?br /> 5 
 6 嵌套表更?/span>Q?/span>table转化再利用表别名操作列进行更?/span>Q?/span>
 7 update table(select S.STUADDS from STUDENT S where
 
8  S.STUNAME = 'improviser') AD set AD.PROVINCE = '北京' where city = 'q州';
 9
10删除嵌套表记?br />11delete from table(select S.STUADDS from STUDENT S
12  
where S.STUNAME = 'improviser') AD where AD.city = '潮州?;
13

    比较Q可变数l,查询速度快,但是更新困难得整体更斎ͼ适用与数据不修改情况Q如ȝ处方。用嵌套表可以对表中的表内容进行修改而无需q行整体更新操作?/font>

4、对象表

 1 首先创徏对象cd
 2 create or replace type OFFICETYPE as object
 3 (
 4     id varchar(10),
 5     typename varchar(20)
 6 );
 7 
 8 对象类型{化ؓ对象?br /> 9 create table office of officetype;
10 
11 创徏对象关系表(使用ref Q指COIDq行对象表关联)
12 create table worker
13 (
14     workerid varchar(10primary key,
15     workername varchar(20),
16     workeroffice ref officetpey scope is office,
17     phone varchar(20)
18 );
19 
20 使用deref 取得兌对象表相兛_?br />21 select workerid,workername,deref(w.workeroffice),phone from worker w
  
where workerid = 'C001';
22 l果?br />23 C001   张小明  OFFICETYPE('0001''财务U?/span>')      010-12345
24 
25 使用VALUE(别名)查询对象内容
26 select value(o) from office o;
27 

5、对象视?/font>
1 创徏对象视图Q通过OIDq接deptQ?br />2 create view deptview of deptype with object oid(deptno) as select *from deptQ?br />3 create view emp_view as select make_ref(deptview,deptno) deptoid,empno,ename
4   from emp;

好了Q有关Oracle中面向对象的内容q要叙q这么多了,虽然现在很少使用刎ͼ但在以后有用C处有一定的参考作用?/font>

  (转蝲h明出?/font>) 


improviser 2007-10-02 11:44 发表评论
]]>
Oracle数据库对?/title><link>http://www.aygfsteel.com/improviser/archive/2007/10/01/150124.html</link><dc:creator>improviser</dc:creator><author>improviser</author><pubDate>Mon, 01 Oct 2007 15:43:00 GMT</pubDate><guid>http://www.aygfsteel.com/improviser/archive/2007/10/01/150124.html</guid><wfw:comment>http://www.aygfsteel.com/improviser/comments/150124.html</wfw:comment><comments>http://www.aygfsteel.com/improviser/archive/2007/10/01/150124.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.aygfsteel.com/improviser/comments/commentRss/150124.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/improviser/services/trackbacks/150124.html</trackback:ping><description><![CDATA[    <font color="#000080" size="4">本文研究有关Oracle数据库对象的用法。Oracle中包含五U数据库对象Q分别ؓ别名、序列、视图、烦引和,其中别名和序列ؓOracle中特有的数据库对象?br /><br />    别名Q通过对Oracle中数据表讄别名之后Q可以用别名对数据表进行与原表名同L各种操作。其语句关键字ؓ<b><font color="#ff0000">synonym</font></b>Q下面看其具体用法?br />    创徏同义词:create <font color="#ff0000">synonym </font>student for stu; <br />    通过创徏后,student即ؓstu表的别名Q因此以下两语句执行l果ZL<br />    select *from student;  ==>   select *from stu;<br />    删除同义词:drop synonym student;<br /><br />    <b>序列Q?/b>作ؓOracle的特有对象,序列用来实现Oracle的主键自增,q是区别于其他关pL据库的。关键字?font color="#ff0000"><b>sequence</b></font>?br />    创徏序列ҎQcreate <b>sequence </b>NumSeq increment <b>by</b> 1 <b>start with</b> 1 <b>maxvalue </b>999;创徏一个序列从1开始递增量ؓ1q设|最大gؓ999?br />    序列使用Qinsert into testTable values(NumSeq.nextVal);<span style="color: blue;" lang="EN-US"><br />        nextVal</span><span lang="EN-US"><span style="">  </span></span><span style="font-family: 宋体;">q回下一个可用的?/span><span style="color: blue;" lang="EN-US">;  <br />        currVal</span><span lang="EN-US"><span style="">  </span></span><span style="font-family: 宋体;">获得当前序列中?/span><span lang="EN-US"><span style="">   </span></span><span style="font-family: 宋体;">W一ơ需先返回一?/span><span lang="EN-US">nextVal</span><span style="font-family: 宋体;">Q才能取?b>curr</b></span><span lang="EN-US">Val</span><span style="font-family: 宋体;">?   <br /></span><span lang="EN-US">        Alter  sequence<span style="">  </span></span><span style="font-family: 宋体;">修改序列定义: alter sequence NumSeq set maxvalue 1000;<br /><br />    <b>视图与烦引:</b>其用法与其他数据库相同,q里不多赘述?br /><br />    <b>:</b></span><span style="font-family: 宋体;">两表或多个表中存在相同列Q将相同列存储在一个空间中Q以节省I间</span>?br />    创徏方法:<br />    create cluser classcluser<br />    (<br />           ClassNo varchar2(10)<br />    );<br />    为簇创徏索引  create index cluserIndex on cluser classcluser;<br /><br />    创徏表StuClassq指向已定义?br />    create table StuClass <br />    (<br />           ClassNo varchar2(10)Q?br />           ClassName varchar2(20)<br />    )cluser classcluser(ClassNo);<br /><br />    创徏表Studentq指向已定义?br />    create table Student<br />    (<br />           StuNo int,<br />           ClassNo varchar2(10)<br />    )cluser classcluser(ClassNo);<br /></font><br /><span style="font-family: 宋体;"></span><img src ="http://www.aygfsteel.com/improviser/aggbug/150124.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/improviser/" target="_blank">improviser</a> 2007-10-01 23:43 <a href="http://www.aygfsteel.com/improviser/archive/2007/10/01/150124.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oracle表分区ȝhttp://www.aygfsteel.com/improviser/archive/2007/10/01/150073.htmlimproviserimproviserMon, 01 Oct 2007 10:00:00 GMThttp://www.aygfsteel.com/improviser/archive/2007/10/01/150073.htmlhttp://www.aygfsteel.com/improviser/comments/150073.htmlhttp://www.aygfsteel.com/improviser/archive/2007/10/01/150073.html#Feedback2http://www.aygfsteel.com/improviser/comments/commentRss/150073.htmlhttp://www.aygfsteel.com/improviser/services/trackbacks/150073.html    今天国庆节,愿大家玩得开心,好好放松Q?br />    我也惛_好放松,到各地旅游,C界每个地?..
    ?..
    ...l箋努力Q!Q?/font>

    不多说题外话了,q入今天主题Q如题,今天对Oracle中表分区机制作个ȝ?br />
   Oracle中提供了对表q行分区的机Ӟ通过表分区,可以表I间中数据按照某U方式分别存攑ֈ特定的分Z?/font>
表分区的作用Q?/font>qIO操作Q分区均匀Q提高效率?br />
   Oracle中表分区Ҏ有:范围分区法、散列分区法、复合分区法、列表分区法?br />
 范围分区:
语法
Partition  by  range(); 适合数值型或日期型
 
CZQ?/font>
 1 create table Student
 2(
 3     Studentid integer not null,
 4     Studentname varchar2(20),
 5     Score integer
 6)
 7 Partition by range(Score)
 8(
 9     Partition p1 values less than(60),
10     Partition p2 values less than(75),
11     Partition p3 values less than(85),
12     Partition p4 values less than(maxvalue)
13 );


  散列分区法:ҎOracle内部散列法存储Q语?Partition by hash();
 
实例Q?/font>
 1 create table department
 2 (
 3     Deptno int,
 4     Deptname varchar2(24)
 5 )
 6 Partition by hash(deptno)
 7 (
 8     Partition p1,
 9     Partition p2
10 );


  复合分区法:׃面两U方法复合而成
  CZQ?/font>
 1 create table salgrade
 2 (
 3     grade number,
 4     losal number,
 5     hisal number
 6 )
 7 Partition by range(grade)
 8 Subpartition by hash(losal,hisal)
 9 (
10     Partition p1 values less than(10),
11       (subpartition sp1,subpartition sp2),
12     Partition p2 values less than(20),
13       (subpartition sp3,subpartition sp4)
14 )


  列表分区法:适合字符?语法Partition by list()
  实例Q?/font>
 1 create table customer
 2 (
 3     custNo int,
 4     custname varchar(20),
 5     custState varchar(20)
 6 )
 7 Partition by list(custState)
 8 (
 9     Partition saia values('中国','韩国','日本'),
10     Partition Europe values('英国','俄国','法国'),
11     Partition ameria values('','加拿?/span>','墨西?/span>'),
12 );
13     


表分区维护:

d分区:alter table student add partition p5 values less than(120);
删除分区:alter table student drop partition p4;
截断分区:alter table student truncate partition p5;
合ƈ分区:alter table student merge partitions p3,p4 into partition p6;

  (转蝲h明出? 


improviser 2007-10-01 18:00 发表评论
]]>
վ֩ģ壺 ȫ| | Ԫ| | | ʳ| | | ǡ| ɳ| ʵ| | | Ϻӿ| | | | | | ӳ| | ׷| | | ǿ| | | Զ| ¹| | Դ| | | | | | | ̶| | | |