??xml version="1.0" encoding="utf-8" standalone="yes"?>男同在线观看,久久99久久精品国产,国产一区二区http://www.aygfsteel.com/joeyeezhang/category/6779.htmlzh-cnSat, 23 Jul 2011 22:16:07 GMTSat, 23 Jul 2011 22:16:07 GMT60PL/SQL developer 使用技?/title><link>http://www.aygfsteel.com/joeyeezhang/archive/2006/11/05/79275.html</link><dc:creator>joeyeezhang</dc:creator><author>joeyeezhang</author><pubDate>Sun, 05 Nov 2006 14:41:00 GMT</pubDate><guid>http://www.aygfsteel.com/joeyeezhang/archive/2006/11/05/79275.html</guid><wfw:comment>http://www.aygfsteel.com/joeyeezhang/comments/79275.html</wfw:comment><comments>http://www.aygfsteel.com/joeyeezhang/archive/2006/11/05/79275.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/joeyeezhang/comments/commentRss/79275.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/joeyeezhang/services/trackbacks/79275.html</trackback:ping><description><![CDATA[<p> <span style="font-family: 宋体;">以下的技巧只针对</span> <span lang="EN-US">PL/SQL Developer 6</span> <span style="font-family: 宋体;">以上版本Q版?/span> <span lang="EN-US">5</span> <span style="font-family: 宋体;">只有其中的部分特性?/span> </p> <p style="text-indent: -18pt;"> <span lang="EN-US"> <span>1Q?span style="font-weight: normal; font-size: 7pt; line-height: normal; font-style: normal; font-variant: normal;"></span></span> </span> <span style="font-family: 宋体;">右键菜单</span> </p> <p> <span style="font-family: 宋体;">?/span> <span lang="EN-US">PL/SQL Developer</span> <span style="font-family: 宋体;">Q下面简U?/span> <span lang="EN-US">PLD</span> <span style="font-family: 宋体;">Q中的每一个文本编辑窗口,?/span> <span lang="EN-US">SQL Window</span> <span style="font-family: 宋体;">Q?/span> <span lang="EN-US">Command Window</span> <span style="font-family: 宋体;">?/span> <span lang="EN-US">Porgram Window</span> <span style="font-family: 宋体;">Q右键点L个对象名Uͼ会弹Z个包含操作对象命令的菜单Q我们这里称之ؓ右键菜单。如下图Q?/span> </p> <p> </p> <p> <span style="font-family: 宋体;">对象cd可以是表Q视图,同义词,存储q程和函数等。根据对象类型的不同Q弹出的菜单也有区别。表和视图有</span> <span lang="EN-US">View, Edit, Rename, Drop, Query data </span> <span style="font-family: 宋体;">?/span> <span lang="EN-US">Edit data</span> <span style="font-family: 宋体;">{功能?/span> <span lang="EN-US">View</span> <span style="font-family: 宋体;">?/span> <span lang="EN-US">Edit</span> <span style="font-family: 宋体;">分别是查看和修改表的l构信息Q如字段Q主键,索引和约束等?/span> <span lang="EN-US">Query data</span> <span style="font-family: 宋体;">相当于新打开一个窗口,q执?/span> <span lang="EN-US">select * from </span> <span style="font-family: 宋体;">表?/span> <span lang="EN-US">Edit data</span> <span style="font-family: 宋体;">相当于新打开一个窗口,q执?/span> <span lang="EN-US">select * from </span> <span style="font-family: 宋体;">?/span> <span lang="EN-US"> for update</span> <span style="font-family: 宋体;">。存储过E和函数?/span> <span lang="EN-US">Test</span> <span style="font-family: 宋体;">功能Q选中后可以进入调试状态?/span> </p> <p> <span style="font-family: 宋体;">有时׃</span> <span lang="EN-US">PLD</span> <span style="font-family: 宋体;">识别错误Q右键点d象ƈ不能出来正确的菜单,可以在对象所在的</span> <span lang="EN-US">DDL</span> <span style="font-family: 宋体;">?/span> <span lang="EN-US">DML</span> <span style="font-family: 宋体;">语句的前面,加上分号Q这?/span> <span lang="EN-US">PLD</span> <span style="font-family: 宋体;">p正确的判断出对象的类?/span> </p> <p style="text-indent: -18pt;"> <span lang="EN-US"> <span>2Q?span style="font-weight: normal; font-size: 7pt; line-height: normal; font-style: normal; font-variant: normal;"></span></span> </span> <span lang="EN-US">Select for Update</span> </p> <p> <span style="font-family: 宋体;">有时我们需要把一些数据导入数据库中,如果?/span> <span lang="EN-US">UE</span> <span style="font-family: 宋体;">?/span> <span lang="EN-US">Insert</span> <span style="font-family: 宋体;">语句Q会比较ȝQ而且操作性不强?/span> <span lang="EN-US">PLD</span> <span style="font-family: 宋体;">?/span> <span lang="EN-US">SQL Window</span> <span style="font-family: 宋体;">可以查询Q新增,修改和删除表的内宏V查询自不必_而新增,删除和修改,只需?/span> <span lang="EN-US">select</span> <span style="font-family: 宋体;">语句后加?/span> <span lang="EN-US">for update</span> <span style="font-family: 宋体;">Q对表进行行U锁定,然后点击H口的锁型图标,卛_q入~辑状态?/span> </p> <p> </p> <p> <span style="font-family: 宋体;">下面介绍一下如何从</span> <span lang="EN-US">Excel</span> <span style="font-family: 宋体;">中提取文本插入到数据库中</span> </p> <p> <span style="font-family: 宋体;">我们?/span> <span lang="EN-US">Excel</span> <span style="font-family: 宋体;">文g中有三列Q?/span> </p> <p> </p> <p> <span style="font-family: 宋体;">在数据库中徏立时表Q?/span> </p> <p> <span lang="EN-US">create table t1 (cino varchar2(100), contno varchar2(100), loanno varchar2(100))</span> </p> <p> <span style="font-family: 宋体;">然后?/span> <span lang="EN-US">SQL Window</span> <span style="font-family: 宋体;">中输?/span> <span lang="EN-US">select t1 for update</span> <span style="font-family: 宋体;">Qƈ点击锁型鼠标Q进入编辑状态:</span> </p> <p> </p> <p> <span style="font-family: 宋体;">用鼠标点ȝ一行的输入H口Q这?/span> <span lang="EN-US">PLD</span> <span style="font-family: 宋体;">会死锁几U钟Q然后可以见到光标在W一行的输入框中闪动Q用鼠标?/span> <span lang="EN-US">CINO, CONTNO, LOANNO</span> <span style="font-family: 宋体;">选中Q?/span> </p> <p> </p> <p> <span style="font-family: 宋体;">q入</span> <span lang="EN-US">Excel</span> <span style="font-family: 宋体;">中,把需要插入数据库的内定w中Q然后切换到</span> <span lang="EN-US">PLD</span> <span style="font-family: 宋体;">Q按</span> <span lang="EN-US">Ctrl + V</span> <span style="font-family: 宋体;">Q?/span> </p> <p> </p> <p> <span style="font-family: 宋体;">点击</span> <span style="font-family: 宋体;">√</span> <span style="font-family: 宋体;">Q然后再点击</span> <span lang="EN-US">Commit</span> <span style="font-family: 宋体;">按钮Q则数据提交到表</span> <span lang="EN-US">t1</span> <span style="font-family: 宋体;">中,执行</span> <span lang="EN-US">select * from t1</span> <span style="font-family: 宋体;">可以看到内容Q?/span> </p> <p style="text-indent: -18pt;"> <span lang="EN-US"> <span>3Q?span style="font-weight: normal; font-size: 7pt; line-height: normal; font-style: normal; font-variant: normal;"></span></span> </span> <span lang="EN-US">PL/SQL Beautifier</span> </p> <p> <span lang="EN-US">PLD 6</span> <span style="font-family: 宋体;">以上版本有对</span> <span lang="EN-US">DML</span> <span style="font-family: 宋体;">代码格式化的功能。在</span> <span lang="EN-US">SQL Window</span> <span style="font-family: 宋体;">?/span> <span lang="EN-US">Program Window</span> <span style="font-family: 宋体;">中选中部分代码Q如果不选则Ҏ个窗口的代码操作Q,在菜单中?/span> <span lang="EN-US">Edit </span> <span style="font-family: Wingdings;" lang="EN-US"> <span>à</span> </span> <span lang="EN-US"> PL/SQL Beautifier</span> <span style="font-family: 宋体;">Q得到格式化的代码。对于非法的</span> <span lang="EN-US">DML</span> <span style="font-family: 宋体;">语句?/span> <span lang="EN-US">DDL</span> <span style="font-family: 宋体;">语句Q?/span> <span lang="EN-US">PLD</span> <span style="font-family: 宋体;">会在下方状态栏提示</span> <span lang="EN-US">PL/SQL Beautifier could not parse text</span> <span style="font-family: 宋体;">?/span> </p> <p> <span style="font-family: 宋体;">在缺省的状态下Q?/span> <span lang="EN-US">PLD</span> <span style="font-family: 宋体;">会把</span> <span lang="EN-US">DML</span> <span style="font-family: 宋体;">语句的每一个字D都排在单独的一行,q样不方便查看。在菜单中?/span> <span lang="EN-US">Edit </span> <span style="font-family: Wingdings;" lang="EN-US"> <span>à</span> </span> <span lang="EN-US"> PL/SQL Beautifier Options</span> <span style="font-family: 宋体;">Q进?/span> <span lang="EN-US">Preferences</span> <span style="font-family: 宋体;">H口Q选择</span> <span lang="EN-US">Edit</span> <span style="font-family: 宋体;">Q进入配|文件编辑界面:</span> </p> <p> </p> <p> <span style="font-family: 宋体;">在标{栏?/span> <span lang="EN-US">DML</span> <span style="font-family: 宋体;">Q在H口中部?/span> <span lang="EN-US">Select, Insert</span> <span style="font-family: 宋体;">?/span> <span lang="EN-US">Update</span> <span style="font-family: 宋体;">l框中把</span> <span lang="EN-US">Fit</span> <span style="font-family: 宋体;">选中Q然后点?/span> <span lang="EN-US">Save</span> <span style="font-family: 宋体;">Q把配置文g保存?/span> <span lang="EN-US">PLD</span> <span style="font-family: 宋体;">的安装目录下Q点?/span> <span lang="EN-US">Close</span> <span style="font-family: 宋体;">关闭。在</span> <span lang="EN-US">Rules file</span> <span style="font-family: 宋体;">中输入配|文件所在位|,点击</span> <span lang="EN-US">OK</span> <span style="font-family: 宋体;">Q完成配|文件切换。这时再对代码进行格式化Q就可以使每一个字D尽可能的在一行上了?/span> </p> <p style="text-indent: -18pt;"> <span lang="EN-US"> <span>4Q?span style="font-weight: normal; font-size: 7pt; line-height: normal; font-style: normal; font-variant: normal;"></span></span> </span> <span lang="EN-US">TNS Names</span> </p> <p> <span style="font-family: 宋体;">菜单</span> <span lang="EN-US">Help </span> <span style="font-family: Wingdings;" lang="EN-US"> <span>à</span> </span> <span lang="EN-US"> Support Info </span> <span style="font-family: Wingdings;" lang="EN-US"> <span>à</span> </span> <span lang="EN-US"> TNS Names</span> <span style="font-family: 宋体;">Q可以查?/span> <span lang="EN-US">Oracle</span> <span style="font-family: 宋体;">?/span> <span lang="EN-US">tnsnames.ora</span> <span style="font-family: 宋体;">?/span> </p> <p style="text-indent: -18pt;"> <span lang="EN-US"> <span>5Q?span style="font-weight: normal; font-size: 7pt; line-height: normal; font-style: normal; font-variant: normal;"></span></span> </span> <span lang="EN-US">Copy to Excel</span> </p> <p> <span style="font-family: 宋体;">?/span> <span lang="EN-US">SQL Window</span> <span style="font-family: 宋体;">中执?/span> <span lang="EN-US">Select</span> <span style="font-family: 宋体;">语句Q在l果出来以后Q右键点M面的数据区,选择</span> <span lang="EN-US">Copy to Excel</span> <span style="font-family: 宋体;">Q可以把数据区的记录原样拯?/span> <span lang="EN-US">Excel</span> <span style="font-family: 宋体;">中。但有两炚w要注意:一Q?/span> <span lang="EN-US">field</span> <span style="font-family: 宋体;">中不能以</span> <span lang="EN-US">=</span> <span style="font-family: 宋体;">开始,否则</span> <span lang="EN-US">Excel</span> <span style="font-family: 宋体;">会误认ؓ是函敎ͼ二,数字不要过</span> <span lang="EN-US">17</span> <span style="font-family: 宋体;">位,否则后面的位数将会置?/span> <span lang="EN-US">0</span> <span style="font-family: 宋体;">Q但可以通过在数字前?#8216;来</span> <span lang="EN-US">Excel</span> <span style="font-family: 宋体;">认ؓ?/span> <span lang="EN-US">field</span> <span style="font-family: 宋体;">是文本,同时对于数据库中</span> <span lang="EN-US">Numbe</span> <span style="font-family: 宋体;">cd的字D,最好用</span> <span lang="EN-US">to_char</span> <span style="font-family: 宋体;">输出Q不然可能会昄不正?/span></p><p><span style="font-family: 宋体;"><a >爱卖?/a><br /></span> </p><img src ="http://www.aygfsteel.com/joeyeezhang/aggbug/79275.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/joeyeezhang/" target="_blank">joeyeezhang</a> 2006-11-05 22:41 <a href="http://www.aygfsteel.com/joeyeezhang/archive/2006/11/05/79275.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>pl/sql?/title><link>http://www.aygfsteel.com/joeyeezhang/archive/2006/11/05/79273.html</link><dc:creator>joeyeezhang</dc:creator><author>joeyeezhang</author><pubDate>Sun, 05 Nov 2006 14:29:00 GMT</pubDate><guid>http://www.aygfsteel.com/joeyeezhang/archive/2006/11/05/79273.html</guid><wfw:comment>http://www.aygfsteel.com/joeyeezhang/comments/79273.html</wfw:comment><comments>http://www.aygfsteel.com/joeyeezhang/archive/2006/11/05/79273.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/joeyeezhang/comments/commentRss/79273.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/joeyeezhang/services/trackbacks/79273.html</trackback:ping><description><![CDATA[ <p align="justify"> <font face="Times New Roman"> <font color="#000080" size="4"> <strong>1.1 </strong> </font> <a name="111"> <font color="#000080" size="4"> <strong>PL/SQL</strong> </font> </a> </font> <font color="#000080" size="4"> <strong>?/strong> </font> <font face="Times New Roman"> </font> </p> <p align="justify"> <font size="4"> <font face="Times New Roman">  <font face="宋体"></font></font> <font face="Verdana">PL/SQL是ORACLE的过E化语言Q包括一整套的数据类型、条件结构、@环结构和异常处理l构QPL/SQL可以执行SQL语句QSQL语句中也可以使用PL/SQL函数?/font> </font> </p> <p align="justify"> <font face="Verdana" size="4"> </font> </p> <p align="justify"> <font color="#000080" size="4"> <strong>1.2 </strong> </font> <a name="222"> <font color="#000080" size="4"> <strong>创徏<font face="Times New Roman">PL/SQL</font>E序?/strong> </font> </a> <font face="Times New Roman"> </font> </p> <p align="justify"> <font face="Times New Roman" size="4">DECLARE<br /></font> <font face="宋体, MS Song" size="4">?br /></font> <font face="Times New Roman" size="4">BEGIN<br /></font> <font face="宋体, MS Song" size="4">?br /></font> <font face="Times New Roman" size="4">EXCEPTION<br />END;</font> </p> <p align="justify"> <font face="Times New Roman" size="4"> </font> </p> <p align="justify"> <font face="Times New Roman" color="#000080" size="4"> <strong>1.3 </strong> </font> <a name="333"> <strong> <font color="#000080"> <font size="4"> <font face="Times New Roman">PL/SQL</font>数据cd</font> </font> </strong> </a> <font size="4"> </font> </p> <table cellspacing="0" cellpadding="0" width="576" border="1"> <tbody> <tr> <td valign="top" width="140"> <p align="justify"> <font size="4">名称</font> </p> </td> <td valign="top" width="71"> <p align="justify"> <font size="4">cd</font> </p> </td> <td valign="top" width="359"> <p align="justify"> <font size="4">说明</font> </p> </td> </tr> <tr> <td valign="top" width="140"> <font face="Times New Roman"> <p align="justify"> <font size="4">NUMBER</font> </p> </font> </td> <td valign="top" width="71"> <p align="justify"> <font size="4">数字?/font> </p> </td> <td valign="top" width="359"> <p align="justify"> <font size="4">能存放整数值和实数|q且可以定义_ֺ和取D?/font> </p> </td> </tr> <tr> <td valign="top" width="140"> <font face="Times New Roman"> <p align="justify"> <font size="4">BINARY_INTEGER</font> </p> </font> </td> <td valign="top" width="71"> <p align="justify"> <font size="4">数字?/font> </p> </td> <td valign="top" width="359"> <p align="justify"> <font size="4">可存储带W号整数Qؓ整数计算优化性能</font> </p> </td> </tr> <tr> <td valign="top" width="140"> <font face="Times New Roman"> <p align="justify"> <font size="4">DEC</font> </p> </font> </td> <td valign="top" width="71"> <p align="justify"> <font size="4">数字?/font> </p> </td> <td valign="top" width="359"> <font face="Times New Roman"> <p align="justify"> <font size="4">NUMBER</font> </p> </font> <font face="宋体, MS Song" size="4">的子cdQ小?/font> </td> </tr> <tr> <td valign="top" width="140"> <font face="Times New Roman"> <p align="justify"> <font size="4">DOUBLE PRECISION</font> </p> </font> </td> <td valign="top" width="71"> <p align="justify"> <font size="4">数字?/font> </p> </td> <td valign="top" width="359"> <font face="Times New Roman"> <p align="justify"> <font size="4">NUMBER</font> </p> </font> <font face="宋体, MS Song" size="4">的子cdQ高_ֺ实数</font> </td> </tr> <tr> <td valign="top" width="140"> <font face="Times New Roman"> <p align="justify"> <font size="4">INTEGER</font> </p> </font> </td> <td valign="top" width="71"> <p align="justify"> <font size="4">数字?/font> </p> </td> <td valign="top" width="359"> <font face="Times New Roman"> <p align="justify"> <font size="4">NUMBER</font> </p> </font> <font face="宋体, MS Song" size="4">的子cdQ整?/font> </td> </tr> <tr> <td valign="top" width="140"> <font face="Times New Roman"> <p align="justify"> <font size="4">INT</font> </p> </font> </td> <td valign="top" width="71"> <p align="justify"> <font size="4">数字?/font> </p> </td> <td valign="top" width="359"> <font face="Times New Roman"> <p align="justify"> <font size="4">NUMBER</font> </p> </font> <font face="宋体, MS Song" size="4">的子cdQ整?/font> </td> </tr> <tr> <td valign="top" width="140"> <font face="Times New Roman"> <p align="justify"> <font size="4">NUMERIC</font> </p> </font> </td> <td valign="top" width="71"> <p align="justify"> <font size="4">数字?/font> </p> </td> <td valign="top" width="359"> <font face="Times New Roman"> <p align="justify"> <font size="4">NUMBER</font> </p> </font> <font size="4"> <font face="宋体, MS Song">的子cdQ与</font> <font face="Times New Roman">NUMBER</font> <font face="宋体, MS Song">{h</font> </font> </td> </tr> <tr> <td valign="top" width="140"> <font face="Times New Roman"> <p align="justify"> <font size="4">REAL</font> </p> </font> </td> <td valign="top" width="71"> <p align="justify"> <font size="4">数字?/font> </p> </td> <td valign="top" width="359"> <font face="Times New Roman"> <p align="justify"> <font size="4">NUMBER</font> </p> </font> <font size="4"> <font face="宋体, MS Song">的子cdQ与</font> <font face="Times New Roman">NUMBER</font> <font face="宋体, MS Song">{h</font> </font> </td> </tr> <tr> <td valign="top" width="140"> <font face="Times New Roman"> <p align="justify"> <font size="4">SMALLINT</font> </p> </font> </td> <td valign="top" width="71"> <p align="justify"> <font size="4">数字?/font> </p> </td> <td valign="top" width="359"> <font face="Times New Roman"> <p align="justify"> <font size="4">NUMBER</font> </p> </font> <font size="4"> <font face="宋体, MS Song">的子cdQ取D围比</font> <font face="Times New Roman">INTEGER</font> <font face="宋体, MS Song">?/font> </font> </td> </tr> <tr> <td valign="top" width="140"> <font face="Times New Roman"> <p align="justify"> <font size="4">VARCHAR2</font> </p> </font> </td> <td valign="top" width="71"> <p align="justify"> <font size="4">字符?/font> </p> </td> <td valign="top" width="359"> <p align="justify"> <font size="4">存放可变长字W串Q有最大长?/font> </p> </td> </tr> <tr> <td valign="top" width="140"> <font face="Times New Roman"> <p align="justify"> <font size="4">CHAR</font> </p> </font> </td> <td valign="top" width="71"> <p align="justify"> <font size="4">字符?/font> </p> </td> <td valign="top" width="359"> <p align="justify"> <font size="4">定长字符?/font> </p> </td> </tr> <tr> <td valign="top" width="140"> <font face="Times New Roman"> <p align="justify"> <font size="4">LONG</font> </p> </font> </td> <td valign="top" width="71"> <p align="justify"> <font size="4">字符?/font> </p> </td> <td valign="top" width="359"> <p align="justify"> <font size="4">变长字符Ԍ最大长度可?font face="Times New Roman">32,767</font></font> </p> </td> </tr> <tr> <td valign="top" width="140"> <font face="Times New Roman"> <p align="justify"> <font size="4">DATE</font> </p> </font> </td> <td valign="top" width="71"> <p align="justify"> <font size="4">日期?/font> </p> </td> <td valign="top" width="359"> <p align="justify"> <font size="4">以数据库相同的格式存放日期?/font> </p> </td> </tr> <tr> <td valign="top" width="140"> <font face="Times New Roman"> <p align="justify"> <font size="4">BOOLEAN</font> </p> </font> </td> <td valign="top" width="71"> <p align="justify"> <font size="4">布尔?/font> </p> </td> <td valign="top" width="359"> <font face="Times New Roman"> <p align="justify"> <font size="4">TRUE OR FALSE</font> </p> </font> </td> </tr> <tr> <td valign="top" width="140"> <font face="Times New Roman"> <p align="justify"> <font size="4">ROWID</font> </p> </font> </td> <td valign="top" width="71"> <font face="Times New Roman"> <p align="justify"> <font size="4">ROWID</font> </p> </font> </td> <td valign="top" width="359"> <p align="justify"> <font size="4">存放数据库的行号</font> </p> </td> </tr> </tbody> </table> <p align="justify"> <font size="4">例子Q?br /></font> <font face="Times New Roman" size="4">DECLARE<br />    ORDER_NO NUMBER(3);<br />    CUST_NAME VARCHAR2(20);<br />    ORDER_DATE DATE;<br />    EMP_NO INTEGER:=25;<br />    PI CONSTANT NUMBER:=3.1416;<br />BEGIN<br />  NULL;<br />END;</font> </p> <p align="justify"> <font face="Times New Roman" size="4"> </font> </p> <p align="justify"> <strong> <font color="#000080" size="4">1.4 </font> </strong> <a name="444"> <strong> <font color="#000080" size="4">处理<font face="Times New Roman">PL/SQL</font>的异?/font> </strong> </a> </p> <p align="justify"> <font face="Times New Roman" size="4"> </font> <font face="黑体"> </font> </p> <p align="justify"> <strong> <font color="#000080"> <font size="4"> <font face="Arial">1.4.1 PL/SQL</font> <font face="Verdana">的异?/font> </font> </font> </strong> </p> <p align="justify"> <font size="4">例如Q?br /></font> <font size="4"> <font face="Times New Roman">DECLARE<br />    X NUMBER;<br />BEGIN<br />    X:= 'yyyy';--Error Here<br /><b>EXCEPTION   WHEN</b> VALUE_ERROR THEN<br />    DBMS_OUTPUT.PUT_LINE('EXCEPTION HANDED');<br /><b>END;</b></font> <font face="Times New Roman"> </font> </font> </p> <p align="justify"> <font size="4">实现技术:<br /></font> <font size="4"> <font face="Times New Roman">EXCEPTION WHEN first_exception THEN<br /></font>?br /></font> <font size="4"> <font face="Times New Roman">WHEN second_exception THEN<br /></font>?br /></font> <font size="4"> <font face="Times New Roman">WHEN OTHERS THEN <br />/*THERS</font>异常<nobr><a class="iAs" oncontextmenu="return false;" onmousemove="kwM(7);" onmouseover="kwE(event,7);" style="CURSOR: hand; COLOR: #0000ff; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline" onclick="window.open('http://211.100.30.165/search/?key=处理?,'_blank');" onmouseout="kwL(event);" target="_blank">处理?/a></nobr>必须排在最后,它处理所有没有明列出的异常?/font> <font size="4"> <font face="Times New Roman">*/<br /></font>?br /><font face="Times New Roman">END;</font></font> </p> <p align="justify"> <strong> <font size="4"> </font> </strong> </p> <p align="left"> <font color="#000080" size="4"> <strong>1.4.2 预定义异?/strong> </font> </p> <p align="justify"> </p> <table cellspacing="0" cellpadding="0" width="568" border="1"> <tbody> <tr> <td valign="top" width="39%"> <p align="center"> <font size="4">异常名称</font> </p> </td> <td valign="top" width="19%"> <font face="Times New Roman"> <p align="center"> <font size="4">ORACLE</font> </p> </font> <font face="宋体, MS Song" size="4">错误</font> </td> <td valign="top" width="42%"> <p align="center"> <font size="4">说明</font> </p> </td> </tr> <tr> <td valign="top" width="39%"> <font face="Times New Roman"> <p align="justify"> <font size="4">CURSOR_ALREADY_OPEN</font> </p> </font> </td> <td valign="top" width="19%"> <font face="Times New Roman"> <p align="justify"> <font size="4">ORA-6511</font> </p> </font> </td> <td valign="top" width="42%"> <p align="justify"> <font size="4">试图打开一个已打开的光?/font> </p> </td> </tr> <tr> <td valign="top" width="39%"> <font face="Times New Roman"> <p align="justify"> <font size="4">DUP_VAL_ON_INDEX</font> </p> </font> </td> <td valign="top" width="19%"> <font face="Times New Roman"> <p align="justify"> <font size="4">ORA-0001</font> </p> </font> </td> <td valign="top" width="42%"> <p align="justify"> <font size="4">试图破坏一个唯一性限?/font> </p> </td> </tr> <tr> <td valign="top" width="39%"> <font face="Times New Roman"> <p align="justify"> <font size="4">INVALID_CURSOR</font> </p> </font> </td> <td valign="top" width="19%"> <font face="Times New Roman"> <p align="justify"> <font size="4">ORA-1001</font> </p> </font> </td> <td valign="top" width="42%"> <p align="justify"> <font size="4">试图使用一个无效的光标</font> </p> </td> </tr> <tr> <td valign="top" width="39%"> <font face="Times New Roman"> <p align="justify"> <font size="4">INVALID_NUMBER</font> </p> </font> </td> <td valign="top" width="19%"> <font face="Times New Roman"> <p align="justify"> <font size="4">ORA-1722</font> </p> </font> </td> <td valign="top" width="42%"> <p align="justify"> <font size="4">试图寚w数字D行数字操?/font> </p> </td> </tr> <tr> <td valign="top" width="39%"> <font face="Times New Roman"> <p align="justify"> <font size="4">LOGIN_DENIED</font> </p> </font> </td> <td valign="top" width="19%"> <font face="Times New Roman"> <p align="justify"> <font size="4">ORA-1017</font> </p> </font> </td> <td valign="top" width="42%"> <p align="justify"> <font size="4">无效的用户名或者口?/font> </p> </td> </tr> <tr> <td valign="top" width="39%"> <font face="Times New Roman"> <p align="justify"> <font size="4">NO_DATA_FOUND</font> </p> </font> </td> <td valign="top" width="19%"> <font face="Times New Roman"> <p align="justify"> <font size="4">ORA-1403</font> </p> </font> </td> <td valign="top" width="42%"> <p align="justify"> <font size="4">查询未找到数?/font> </p> </td> </tr> <tr> <td valign="top" width="39%"> <font face="Times New Roman"> <p align="justify"> <font size="4">NOT_LOGGED_ON</font> </p> </font> </td> <td valign="top" width="19%"> <font face="Times New Roman"> <p align="justify"> <font size="4">ORA-1012</font> </p> </font> </td> <td valign="top" width="42%"> <p align="justify"> <font size="4">q未q接p图数据库操作</font> </p> </td> </tr> <tr> <td valign="top" width="39%"> <font face="Times New Roman"> <p align="justify"> <font size="4">PROGRAM_ERROR</font> </p> </font> </td> <td valign="top" width="19%"> <font face="Times New Roman"> <p align="justify"> <font size="4">ORA-6501</font> </p> </font> </td> <td valign="top" width="42%"> <p align="justify"> <font size="4">内部错误</font> </p> </td> </tr> <tr> <td valign="top" width="39%"> <font face="Times New Roman"> <p align="justify"> <font size="4">ROWTYPE_MISMATCH</font> </p> </font> </td> <td valign="top" width="19%"> <font face="Times New Roman"> <p align="justify"> <font size="4">ORA-6504</font> </p> </font> </td> <td valign="top" width="42%"> <p align="justify"> <font size="4">d量和光标的类型不兼容</font> </p> </td> </tr> <tr> <td valign="top" width="39%"> <font face="Times New Roman"> <p align="justify"> <font size="4">STORAGE_ERROR</font> </p> </font> </td> <td valign="top" width="19%"> <font face="Times New Roman"> <p align="justify"> <font size="4">ORA-6500</font> </p> </font> </td> <td valign="top" width="42%"> <p align="justify"> <font size="4">内部错误</font> </p> </td> </tr> <tr> <td valign="top" width="39%"> <font face="Times New Roman"> <p align="justify"> <font size="4">TIMEOUT_ON_RESOURCE</font> </p> </font> </td> <td valign="top" width="19%"> <font face="Times New Roman"> <p align="justify"> <font size="4">ORA-0051</font> </p> </font> </td> <td valign="top" width="42%"> <p align="justify"> <font size="4">发生时</font> </p> </td> </tr> <tr> <td valign="top" width="39%"> <font face="Times New Roman"> <p align="justify"> <font size="4">TOO_MANY_ROWS</font> </p> </font> </td> <td valign="top" width="19%"> <font face="Times New Roman"> <p align="justify"> <font size="4">ORA-1422</font> </p> </font> </td> <td valign="top" width="42%"> <font face="Times New Roman"> <p align="justify"> <font size="4">SELECT INTD</font> </p> </font> <font face="宋体, MS Song" size="4">命oq回的多?/font> </td> </tr> <tr> <td valign="top" width="39%"> <font face="Times New Roman"> <p align="justify"> <font size="4">TRANSACTION_BACKED_OUT</font> </p> </font> </td> <td valign="top" width="19%"> <font face="Times New Roman"> <p align="justify"> <font size="4">ORA-006</font> </p> </font> </td> <td valign="top" width="42%"> <p align="justify"> <font size="4">׃死锁提交被退?/font> </p> </td> </tr> <tr> <td valign="top" width="39%"> <font face="Times New Roman"> <p align="justify"> <font size="4">VALUE_ERROR</font> </p> </font> </td> <td valign="top" width="19%"> <font face="Times New Roman"> <p align="justify"> <font size="4">ORA-6502</font> </p> </font> </td> <td valign="top" width="42%"> <p align="justify"> <font size="4">转换或者裁剪错?/font> </p> </td> </tr> <tr> <td valign="top" width="39%"> <font face="Times New Roman"> <p align="justify"> <font size="4">ZERO_DIVIDE</font> </p> </font> </td> <td valign="top" width="19%"> <font face="Times New Roman"> <p align="justify"> <font size="4">ORA-1476</font> </p> </font> </td> <td valign="top" width="42%"> <p align="justify"> <font size="4">试图被零?/font> </p> </td> </tr> </tbody> </table> <p align="justify"> <font size="4"> </font> </p> <font face="Times New Roman"> <p align="justify"> <font face="黑体"> <font color="#000080"> <font size="4"> <strong>1.4.3</strong> </font> </font> <a name="_Toc439229533"> <font color="#000080" size="4">自定义异常处?/font> </a> </font> <font face="Times New Roman"> </font> </p> <p align="justify"> </p> </font> <font size="4"> <font face="Times New Roman">DECLARE<br />    BAD_ROWID EXCEPTION;<br />    X ROWID;<br />PRAGMA EXCEPTION_INIT(BAD_ROWID,-01445);<br />BEGIN<br />    SELECT ROWID INTO X FROM TAB<br />    WHERE ROWNUM=1;<br />EXCEPTION WHEN BAD_ROWID THEN<br />    DBMS_OUTPUT.PUT_LINE('CANNOT QUERY ROWID FROM THIS VIEW');<br />END;<br /><br /></font> <font face="宋体, MS Song">    注意Q?/font> <font face="Times New Roman">-01445 </font> <font face="宋体, MS Song">因ؓ</font> <font face="Times New Roman">PRAGMA EXCEPTION_INIT</font> <font face="宋体, MS Song">命o把这个变?/font> <font face="Times New Roman">(-01455)</font> </font> <font size="4"> <font face="宋体, MS Song">q接?br />q个</font> <font face="Times New Roman">ORACLE</font> </font> <font face="宋体, MS Song" size="4">错误Q该语句的语法如下:<br />    </font> <font size="4"> <font face="Times New Roman">PRAGMA EXCEPTION_INIT(exception_name, error_number);<br /></font> <font face="宋体, MS Song">其中</font> <font face="Times New Roman">error_number</font> <font face="宋体, MS Song">是负敎ͼ因ؓ错误可认ؓ负数Q当定义错误时记住用负?/font> </font> <p align="justify"> <strong> <font face="Times New Roman" size="4"> </font> </strong> </p> <p align="justify"> <font face="宋体, MS Song" color="#000080" size="4"> <strong>1.4.4 </strong> </font> <a name="_Toc439229534"> <font face="宋体, MS Song" color="#000080" size="4"> <strong>自定义异?/strong> </font> </a> </p> <p align="justify"> <font size="4"> <font face="宋体, MS Song">    异常不一定必L</font> <font face="Times New Roman">oracle</font> </font> <font face="宋体, MS Song" size="4">q回的系l错误,用户可以在自q应用E序中创<br />建可触发及可处理的自定义异常<br /></font> <font size="4"> <font face="Times New Roman">DECLARE<br />    SALARY_CODE VARCHAR2(1);<br />    INVALID_SALARY_CODE EXCEPTION;<br />BEGIN<br />    SALARY_CODE:='X';<br />    IF SALARY_CODE NOT IN('A', 'B', 'C') THEN<br />    RAISE INVALID_SALARY_CODE;<br />    END IF;<br />EXCEPTION WHEN INVALID_SALARY_CODE THEN<br />    DBMS_OUTPUT.PUT_LINE('INVALID SALARY CODE');<br />END;</font> <br /> </font> <font face="Times New Roman"> <strong> <font size="4"> </font> </strong> </font> </p> <p align="justify"> <font face="宋体, MS Song" color="#000080" size="4"> <strong>1.5 </strong> </font> <a name="555"> <font color="#000080"> <strong> <font size="4"> <font face="宋体, MS Song">?/font> <font face="Times New Roman">PL/SQL</font> <font face="宋体, MS Song">中单条记录的查询</font> </font> </strong> </font> </a> </p> <p align="justify"> <font face="宋体, MS Song" size="4">    在PL/SQL内,有时在没有定义显式光标的情况下需要查询单条记录,q把记录的数据赋l变量?br />DECLARE<br />    ln_dno NUMBER;<br />    lvs_dname VARCHAR2(40);<br />BEGIN<br />    SELECT DEPT_NO,DEPT_NAME<br />        INTO ln_dno,lvs_dname<br />    FROM dept<br />    WHERE DEPT_NO=1;<br />    DBMS_OUTPUT.PUT_LINE(TO_CHAR(ln_dno)||'.'||lvs_dname);<br />EXCEPTION WHEN NO_DATA_FOUND THEN<br />    DBMS_OUTPUT.PUT_LINE('NO DATA_FOUND<b>'</b>)</font> <font face="宋体, MS Song"> <font size="4"> <b>;<br /></b>    WHEN TOO_MANY_ROWS THEN<br />    DBMS_OUTPUT.PUT_LINE('TOO_MANY_ROWS');<br />END;</font> </font> </p> <p align="justify"> <font size="4"> </font> </p> <p align="justify"> <b> <font color="#000080" size="4">1.6 </font> <a name="666"> <font color="#000080" size="4">用光标查询多条记?/font> </a> </b> <font face="Times New Roman"> </font> </p> <p align="justify"> <font face="宋体, MS Song" size="4">      光标QCURSORQ是指向一个称Z下文相关区的区域的指针,q个区域?nobr><a class="iAs" oncontextmenu="return false;" onmousemove="kwM(8);" onmouseover="kwE(event,8);" style="CURSOR: hand; COLOR: #0000ff; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline" onclick="window.open('http://211.100.30.165/search/?key=服务?,'_blank');" onmouseout="kwL(event);" target="_blank">服务?/a></nobr>的处理过E全局区(PGAQ内Q当服务器上执行了一个查询后Q查询返回的记录集存攑֜上下文相兛_Q通过光标上的操作可以把这些记录检索到客户端的应用E序?/font> </p> <p align="justify"> <font size="4"> </font> </p> <p align="justify"> <font face="黑体"> <font color="#000080"> <font size="4"> <strong>1.6.1</strong> </font> </font> <a name="_Toc439229537"> <font color="#000080" size="4">使用光标的基本方?/font> </a> </font> <font face="Times New Roman"> </font> </p> <p align="justify"> <font size="4">DECLARE<br />    CURSOR C1 IS SELECT VIEW_NAME FROM ALL_VIEWS<br />        WHERE ROWNUM<=10<br />        ORDER BY VIEW_NAME;<br />    VNAME VARCHAR2(40);<br />BEGIN<br />    OPEN C1;<br />    FETCH C1 INTO VNAME;<br />    WHILE C1%FOUND LOOP<br />        DBMS_OUTPUT.PUT_LINE(TO_CHAR(C1%ROWCOUNT)||' '||VNAME);<br />        FETCH C1 INTO VNAME;<br />    END LOOP;<br />END;</font> </p> <p align="justify"> </p> <table cellspacing="0" cellpadding="0" width="568" border="1"> <tbody> <tr> <td valign="top" width="20%"> <p align="center"> <font size="4">属?/font> </p> </td> <td valign="top" width="80%"> <p align="center"> <font size="4">含量</font> </p> </td> </tr> <tr> <td valign="top" width="20%"> <p align="justify"> <font size="4">%FOUND</font> </p> </td> <td valign="top" width="80%"> <p align="justify"> <font size="4">布尔型属性,当最q一ơ该记录时成功返回,则gؓTRUE</font> </p> </td> </tr> <tr> <td valign="top" width="20%"> <p align="justify"> <font size="4">%NOTFOUND</font> </p> </td> <td valign="top" width="80%"> <p align="justify"> <font size="4">布尔型属性,它的值M%FOUND属性的值相?/font> </p> </td> </tr> <tr> <td valign="top" width="20%"> <p align="justify"> <font size="4">%ISOPEN</font> </p> </td> <td valign="top" width="80%"> <p align="justify"> <font size="4">布尔型属性,当光标是打开时返回TRUE</font> </p> </td> </tr> <tr> <td valign="top" width="20%"> <p align="justify"> <font size="4">%ROWCOUNT</font> </p> </td> <td valign="top" width="80%"> <p align="justify"> <font size="4">数字型属性,q回已从光标中读取的记录?/font> </p> </td> </tr> </tbody> </table> <p> <font face="黑体"> <strong> <font size="4"> </font> </strong> </font> </p> <p align="justify"> <font face="黑体"> <font color="#000080"> <font size="4"> <strong>1.6.2</strong> </font> </font> <a name="_Toc439229538"> <font color="#000080" size="4">使用光标</font> </a> </font> <font color="#000080"> <font size="4"> <font face="Arial"> <strong>FOR</strong> </font> <font face="黑体">循环</font> </font> </font> <font face="Times New Roman"> </font> </p> <p align="justify"> <font size="4">DECLARE<br />    CURSOR C1 IS<br />    SELECT VIEW_NAME<br />        FROM ALL_VIEWS<br />        WHERE ROWNUM<=10<br />        ORDER BY VIEW_NAME;<br />BEGIN<br />    FOR I IN C1 LOOP<br />        DBMS_OUTPUT.PUT_LINE(I.VIEW_NAME);<br />    END LOOP;<br />END LOOP;<br />EXCEPTION WHEN OTHERS THEN<br />    NULL;<br />END;</font> </p> <p align="justify"> <font size="4"> </font> </p> <font face="黑体"> <p align="justify"> </p> </font> <font face="黑体"> <font color="#000080" size="4"> <strong>1.6.3 </strong> </font> <a name="_Toc439229539"> <font color="#000080" size="4">带参数的光标</font> </a> </font> <font face="Times New Roman"> </font> <p> <font size="4">DECLARE<br />    CURSOR C1(VIEW_PATTERN VARCHAR2) IS<br />        SELECT VIEW_NAME<br />        FROM ALL_VIEWS<br />        WHERE VIEW_NAME LIKE VIEW_PATTERN||'%' AND<br />        ROWNUM<=10<br />        ORDER BY VIEW_NAME;<br />    VNAME VARCHAR2(40);<br />BEGIN<br />    FOR I IN C1('USER_AR') LOOP<br />        DBMS_OUTPUT.PUT_LINE(I.VIEW_NAME);<br />    END LOOP;<br />    DBMS_OUTPUT.PUT_LINE(?;<br />    FOR I IN C1('USER') LOOP<br />        DBMS_OUTPUT.PUT_LINE(I.VIEW_NAME);<br />    END LOOP;<br />EXCEPTION WHEN OTHERS THEN<br />    DBMS_OUTPUT.PUT_LINE('AAA');<br />END;</font> </p> <p> <font size="4"> </font> </p> <p> <font color="#000080" size="4"> <strong>1.7 </strong> </font> <a name="777"> <font color="#000080" size="4"> <strong>创徏代表数据库记录和列的变量</strong> </font> </a> </p> <p align="justify"> <font size="4">变量??font face="Times New Roman">.</font>列名</font> <font size="4"> <font face="Times New Roman">%TYPE<br />DECLARE<br />    D_NO DEPT.DEPT_NO%TYPE;<br />    D_NAME DEPT.DEPT_NAME%TYPE;<br />BEGIN<br />    SELECT DEPT_NO,DEPT_NAME INTO D_NO,D_NAME<br />    FROM DEPT;<br />    DBMS_OUTPUT.PUT_LINE(TO_CHAR(D_NO));<br />EXCEPTION WHEN NO_DATA_FOUND THEN<br />    NULL;<br />END;<br /><br /></font>变量??/font> <font size="4"> <font face="Times New Roman">%ROWTYPE<br />DECLARE<br />    D VEQU12%ROWTYPE;<br />BEGIN<br />    SELECT ASSET12ID,ASSET12NAME<br />        INTO D.ASSET12ID, D.ASSET12NAME<br />        FROM VEQU12;<br />    DBMS_OUTPUT.PUT_LINE(D.ASSET12ID);<br />EXCEPTION<br />WHEN NO_DATA_FOUND THEN<br />    NULL;<br />WHEN TOO_MANY_ROWS THEN<br />    DBMS_OUTPUT.PUT_LINE('TOO_MANY_ROWS');<br />END;<br /></font>说明Q?br /><font face="Times New Roman">    </font>当用戯创徏一个变量来表示一个基表列或者要创徏多个变量来代表一整条记录Ӟ可以实际使用<font face="Times New Roman">%TYPE</font>属性和<font face="Times New Roman">%ROWTYPE</font>属性,使用<font face="Times New Roman">%TYPE</font>属性和<font face="Times New Roman">%ROWTYPE</font>属性可以保证当的结构或者其中某列的数据cd改变了时Q用L<font face="Times New Roman">PL/SQL</font>代码仍可正常<nobr><a class="iAs" oncontextmenu="return false;" onmousemove="kwM(9);" onmouseover="kwE(event,9);" style="CURSOR: hand; COLOR: #0000ff; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline" onclick="window.open('http://211.100.30.165/search/?key=工作','_blank');" onmouseout="kwL(event);" target="_blank">工作</a></nobr>?/font> </p> <p align="justify"> <font size="4"> <font face="Times New Roman"> </font> </font> </p> <b> <p align="justify"> <font color="#000080" size="4">1.8 </font> <a name="999"> <font color="#000080" size="4">怎样?font face="Times New Roman">PL/SQL</font>表实现数l功?/font> </a> </p> </b> <font face="Times New Roman"> </font> <p align="justify"> <font size="4">    PL/SQL表与其他q程化语a(如C语言)的一l数l类伹{实现PL/SQL表需要创Z个数据类型ƈ另外q行变量说明?br />    Type <cd?gt; Is<br />    Table Of <数据cd><br />    Index by Binary_Integer;<br />以下Z个例子:<br />Declare<br />    Type Array_type is<br />        Table Of Number<br />        Index by Binary_Integer;<br />    My_Array Array_type;<br />Begin<br />    For I In 1..10 Loop<br />        My_Array(I) := I*2;<br />    End Loop;<br />    For I In 1..10 Loop<br />        Dbms_Output.Put_line(To_char(My_Array(I)));<br />    End Loop;<br />End;</font> </p> <img src ="http://www.aygfsteel.com/joeyeezhang/aggbug/79273.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/joeyeezhang/" target="_blank">joeyeezhang</a> 2006-11-05 22:29 <a href="http://www.aygfsteel.com/joeyeezhang/archive/2006/11/05/79273.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>oracle常用函数http://www.aygfsteel.com/joeyeezhang/archive/2006/11/04/79095.htmljoeyeezhangjoeyeezhangSat, 04 Nov 2006 11:16:00 GMThttp://www.aygfsteel.com/joeyeezhang/archive/2006/11/04/79095.htmlhttp://www.aygfsteel.com/joeyeezhang/comments/79095.htmlhttp://www.aygfsteel.com/joeyeezhang/archive/2006/11/04/79095.html#Feedback0http://www.aygfsteel.com/joeyeezhang/comments/commentRss/79095.htmlhttp://www.aygfsteel.com/joeyeezhang/services/trackbacks/79095.htmlORACLE内置函数大全                                       

ORACLE内置函数大全

SQL中的单记录函?br />1.ASCII
q回与指定的字符对应的十q制?
SQL> select ascii('A') A,ascii('a') a,ascii('0') zero,ascii(' ') space from dual;

        A         A      ZERO     SPACE
--------- --------- --------- ---------
       65        97        48        32


2.CHR
l出整数,q回对应的字W?
SQL> select chr(54740) zhao,chr(65) chr65 from dual;

ZH C
-- -
?A

3.CONCAT
q接两个字符?
SQL> select concat('010-','88888888')||'?3'  高乾竞电?from dual;

高乾竞电?br />----------------
010-88888888?3

4.INITCAP
q回字符串ƈ字W串的第一个字母变为大?
SQL> select initcap('smith') upp from dual;

UPP
-----
Smith


5.INSTR(C1,C2,I,J)
在一个字W串中搜索指定的字符,q回发现指定的字W的位置;
C1    被搜索的字符?br />C2    希望搜烦的字W串
I     搜烦的开始位|?默认?
J     出现的位|?默认?
SQL> select instr('oracle traning','ra',1,2) instring from dual;

 INSTRING
---------
        9


6.LENGTH
q回字符串的长度;
SQL> select name,length(name),addr,length(addr),sal,length(to_char(sal)) from gao.nchar_tst;

NAME   LENGTH(NAME) ADDR             LENGTH(ADDR)       SAL LENGTH(TO_CHAR(SAL))
------ ------------ ---------------- ------------ --------- --------------------
高乾竞          ?3 北京市v锭区                6   9999.99                    7

 

7.LOWER
q回字符?q将所有的字符写
SQL> select lower('AaBbCcDd')AaBbCcDd from dual;

AABBCCDD
--------
aabbccdd


8.UPPER
q回字符?q将所有的字符大写
SQL> select upper('AaBbCcDd') upper from dual;

UPPER
--------
AABBCCDD

 

9.RPAD和LPAD(_脓字符)
RPAD  在列的右边粘贴字W?br />LPAD  在列的左边粘贴字W?br />SQL> select lpad(rpad('gao',10,'*'),17,'*')from dual;

LPAD(RPAD('GAO',1
-----------------
*******gao*******
不够字符则用*来填?/font>


10.LTRIM和RTRIM
LTRIM  删除左边出现的字W串
RTRIM  删除双出现的字W串
SQL> select ltrim(rtrim('   gao qian jing   ',' '),' ') from dual;

LTRIM(RTRIM('
-------------
gao qian jing


11.SUBSTR(string,start,count)
取子字符?从start开?取count?br />SQL> select substr('13088888888',3,8) from dual;

SUBSTR('
--------
08888888


12.REPLACE('string','s1','s2')
string   希望被替换的字符或变?
s1       被替换的字符?br />s2       要替换的字符?br />SQL> select replace('he love you','he','i') from dual;

REPLACE('H
----------
i love you


13.SOUNDEX
q回一个与l定的字W串读音相同的字W串
SQL> create table table1(xm varchar(8));
SQL> insert into table1 values('weather');
SQL> insert into table1 values('wether');
SQL> insert into table1 values('gao');

SQL> select xm from table1 where soundex(xm)=soundex('weather');

XM
--------
weather
wether


14.TRIM('s' from 'string')
LEADING   剪掉前面的字W?br />TRAILING  剪掉后面的字W?br />如果不指?默认为空格符

15.ABS
q回指定值的l对?br />SQL> select abs(100),abs(-100) from dual;

 ABS(100) ABS(-100)
--------- ---------
      100       100


16.ACOS
l出反余弦的?br />SQL> select acos(-1) from dual;

 ACOS(-1)
---------
3.1415927


17.ASIN
l出反正弦的?br />SQL> select asin(0.5) from dual;

ASIN(0.5)
---------
.52359878


18.ATAN
q回一个数字的反正切?br />SQL> select atan(1) from dual;

  ATAN(1)
---------
.78539816


19.CEIL
q回大于或等于给出数字的最整?br />SQL> select ceil(3.1415927) from dual;

CEIL(3.1415927)
---------------
              4


20.COS
q回一个给定数字的余u
SQL> select cos(-3.1415927) from dual;

COS(-3.1415927)
---------------
             -1


21.COSH
q回一个数字反余u?br />SQL> select cosh(20) from dual;

 COSH(20)
---------
242582598


22.EXP
q回一个数字e的nơ方?br />SQL> select exp(2),exp(1) from dual;

   EXP(2)    EXP(1)
--------- ---------
7.3890561 2.7182818


23.FLOOR
对给定的数字取整?br />SQL> select floor(2345.67) from dual;

FLOOR(2345.67)
--------------
          2345


24.LN
q回一个数字的Ҏ?br />SQL> select ln(1),ln(2),ln(2.7182818) from dual;

    LN(1)     LN(2) LN(2.7182818)
--------- --------- -------------
        0 .69314718     .99999999


25.LOG(n1,n2)
q回一个以n1为底n2的对?
SQL> select log(2,1),log(2,4) from dual;

 LOG(2,1)  LOG(2,4)
--------- ---------
        0         2


26.MOD(n1,n2)
q回一个n1除以n2的余?br />SQL> select mod(10,3),mod(3,3),mod(2,3) from dual;

MOD(10,3)  MOD(3,3)  MOD(2,3)
--------- --------- ---------
        1         0         2


27.POWER
q回n1的n2ơ方?br />SQL> select power(2,10),power(3,3) from dual;

POWER(2,10) POWER(3,3)
----------- ----------
       1024         27


28.ROUND和TRUNC
按照指定的精度进行舍?br />SQL> select round(55.5),round(-55.4),trunc(55.5),trunc(-55.5) from dual;

ROUND(55.5) ROUND(-55.4) TRUNC(55.5) TRUNC(-55.5)
----------- ------------ ----------- ------------
         56          -55          55          -55


29.SIGN
取数字n的符?大于0q回1,于0q回-1,{于0q回0
SQL> select sign(123),sign(-100),sign(0) from dual;

SIGN(123) SIGN(-100)   SIGN(0)
--------- ---------- ---------
        1         -1         0


30.SIN
q回一个数字的正u?br />SQL> select sin(1.57079) from dual;

SIN(1.57079)
------------
           1


31.SIGH
q回双曲正u的?br />SQL> select sin(20),sinh(20) from dual;

  SIN(20)  SINH(20)
--------- ---------
.91294525 242582598


32.SQRT
q回数字n的根
SQL> select sqrt(64),sqrt(10) from dual;

 SQRT(64)  SQRT(10)
--------- ---------
        8 3.1622777


33.TAN
q回数字的正切?br />SQL> select tan(20),tan(10) from dual;

  TAN(20)   TAN(10)
--------- ---------
2.2371609 .64836083


34.TANH
q回数字n的双曲正切?br />SQL> select tanh(20),tan(20) from dual;

 TANH(20)   TAN(20)
--------- ---------
        1 2.2371609

 

35.TRUNC
按照指定的精度截取一个数
SQL> select trunc(124.1666,-2) trunc1,trunc(124.16666,2) from dual;

   TRUNC1 TRUNC(124.16666,2)
--------- ------------------
      100             124.16

 

36.ADD_MONTHS
增加或减L?br />SQL> select to_char(add_months(to_date('199912','yyyymm'),2),'yyyymm') from dual;

TO_CHA
------
200002
SQL> select to_char(add_months(to_date('199912','yyyymm'),-2),'yyyymm') from dual;

TO_CHA
------
199910


37.LAST_DAY
q回日期的最后一?br />SQL> select to_char(sysdate,'yyyy.mm.dd'),to_char((sysdate)+1,'yyyy.mm.dd') from dual;

TO_CHAR(SY TO_CHAR((S
---------- ----------
2004.05.09 2004.05.10
SQL> select last_day(sysdate) from dual;

LAST_DAY(S
----------
31-5?-04


38.MONTHS_BETWEEN(date2,date1)
l出date2-date1的月?br />SQL> select months_between('19-12?1999','19-3?1999') mon_between from dual;

MON_BETWEEN
-----------
          9
SQL>selectmonths_between(to_date('2000.05.20','yyyy.mm.dd'),to_date('2005.05.20','yyyy.mm.dd')) mon_betw from dual;

 MON_BETW
---------
      -60


39.NEW_TIME(date,'this','that')
l出在this时区=other时区的日期和旉
SQL> select to_char(sysdate,'yyyy.mm.dd hh24:mi:ss') bj_time,to_char(new_time
  2  (sysdate,'PDT','GMT'),'yyyy.mm.dd hh24:mi:ss') los_angles from dual;

BJ_TIME             LOS_ANGLES
------------------- -------------------
2004.05.09 11:05:32 2004.05.09 18:05:32


40.NEXT_DAY(date,'day')
l出日期date和星期x之后计算下一个星期的日期
SQL> select next_day('18-5?2001','星期?) next_day from dual;

NEXT_DAY
----------
25-5?-01

 

41.SYSDATE
用来得到pȝ的当前日?br />SQL> select to_char(sysdate,'dd-mm-yyyy day') from dual;

TO_CHAR(SYSDATE,'
-----------------
09-05-2004 星期?br />trunc(date,fmt)按照l出的要求将日期截断,如果fmt='mi'表示保留?截断U?br />SQL> select to_char(trunc(sysdate,'hh'),'yyyy.mm.dd hh24:mi:ss') hh,
  2  to_char(trunc(sysdate,'mi'),'yyyy.mm.dd hh24:mi:ss') hhmm from dual;

HH                  HHMM
------------------- -------------------
2004.05.09 11:00:00 2004.05.09 11:17:00

 

42.CHARTOROWID
字W数据类型{换ؓROWIDcd
SQL> select rowid,rowidtochar(rowid),ename from scott.emp;

ROWID              ROWIDTOCHAR(ROWID) ENAME
------------------ ------------------ ----------
AAAAfKAACAAAAEqAAA AAAAfKAACAAAAEqAAA SMITH
AAAAfKAACAAAAEqAAB AAAAfKAACAAAAEqAAB ALLEN
AAAAfKAACAAAAEqAAC AAAAfKAACAAAAEqAAC WARD
AAAAfKAACAAAAEqAAD AAAAfKAACAAAAEqAAD JONES


43.CONVERT(c,dset,sset)
源字符?sset从一个语a字符集{换到另一个目的dset字符?br />SQL> select convert('strutz','we8hp','f7dec') "conversion" from dual;

conver
------
strutz


44.HEXTORAW
一个十六进制构成的字符串{换ؓ二进?/font>


45.RAWTOHEXT
一个二q制构成的字W串转换为十六进?/font>

 

46.ROWIDTOCHAR
ROWID数据cd转换为字W类?/font>

 

47.TO_CHAR(date,'format')
SQL> select to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') from dual;

TO_CHAR(SYSDATE,'YY
-------------------
2004/05/09 21:14:41

 

48.TO_DATE(string,'format')
字W串转化为ORACLE中的一个日?/font>


49.TO_MULTI_BYTE
字W串中的单字节字W{化ؓ多字节字W?br />SQL>  select to_multi_byte('?) from dual;

TO
--
?/font>


50.TO_NUMBER
给出的字符转换为数?br />SQL> select to_number('1999') year from dual;

     YEAR
---------
     1999


51.BFILENAME(dir,file)
指定一个外部二q制文g
SQL>insert into file_tb1 values(bfilename('lob_dir1','image1.gif'));


52.CONVERT('x','desc','source')
x字段或变量的源source转换为desc
SQL> select sid,serial#,username,decode(command,
  2  0,'none',
  3  2,'insert',
  4  3,
  5  'select',
  6  6,'update',
  7  7,'delete',
  8  8,'drop',
  9  'other') cmd  from v$session where type!='background';

      SID   SERIAL# USERNAME                       CMD
--------- --------- ------------------------------ ------
        1         1                                none
        2         1                                none
        3         1                                none
        4         1                                none
        5         1                                none
        6         1                                none
        7      1275                                none
        8      1275                                none
        9        20 GAO                            select
       10        40 GAO                            none


53.DUMP(s,fmt,start,length)
DUMP函数以fmt指定的内部数字格式返回一个VARCHAR2cd的?br />SQL> col global_name for a30
SQL> col dump_string for a50
SQL> set lin 200
SQL> select global_name,dump(global_name,1017,8,5) dump_string from global_name;

GLOBAL_NAME                    DUMP_STRING
------------------------------ --------------------------------------------------
ORACLE.WORLD                   Typ=1 Len=12 CharacterSet=ZHS16GBK: W,O,R,L,D


54.EMPTY_BLOB()和EMPTY_CLOB()
q两个函数都是用来对大数据类型字D进行初始化操作的函?/font>


55.GREATEST
q回一l表辑ּ中的最大?x较字W的~码大小.
SQL> select greatest('AA','AB','AC') from dual;

GR
--
AC
SQL> select greatest('?,'?,'?) from dual;

GR
--
?/font>


56.LEAST
q回一l表辑ּ中的最?
SQL> select least('?,'?,'?) from dual;

LE
--
?/font>


57.UID
q回标识当前用户的唯一整数
SQL> show user
USER ?GAO"
SQL> select username,user_id from dba_users where user_id=uid;

USERNAME                         USER_ID
------------------------------ ---------
GAO                                   25

 

58.USER
q回当前用户的名?br />SQL> select user from  dual;

USER
------------------------------
GAO


59.USEREVN
q回当前用户环境的信?opt可以?
ENTRYID,SESSIONID,TERMINAL,ISDBA,LABLE,LANGUAGE,CLIENT_INFO,LANG,VSIZE
ISDBA  查看当前用户是否是DBA如果是则q回true
SQL> select userenv('isdba') from dual;

USEREN
------
FALSE
SQL> select userenv('isdba') from dual;

USEREN
------
TRUE
SESSION
q回会话标志
SQL> select userenv('sessionid') from dual;

USERENV('SESSIONID')
--------------------
                 152
ENTRYID
q回会话人口标志
SQL> select userenv('entryid') from dual;

USERENV('ENTRYID')
------------------
                 0
INSTANCE
q回当前INSTANCE的标?br />SQL> select userenv('instance') from dual;

USERENV('INSTANCE')
-------------------
                  1
LANGUAGE
q回当前环境变量
SQL> select userenv('language') from dual;

USERENV('LANGUAGE')
----------------------------------------------------
SIMPLIFIED CHINESE_CHINA.ZHS16GBK
LANG
q回当前环境的语a的羃?br />SQL> select userenv('lang') from dual;

USERENV('LANG')
----------------------------------------------------
ZHS
TERMINAL
q回用户的终端或机器的标?br />SQL> select userenv('terminal') from dual;

USERENV('TERMINA
----------------
GAO
VSIZE(X)
q回X的大?字节)?br />SQL> select vsize(user),user from dual;

VSIZE(USER) USER
----------- ------------------------------
          6 SYSTEM

 

60.AVG(DISTINCT|ALL)
all表示Ҏ有的值求q_?distinct只对不同的值求q_?br />SQLWKS> create table table3(xm varchar(8),sal number(7,2));
语句已处理?br />SQLWKS>  insert into table3 values('gao',1111.11);
SQLWKS>  insert into table3 values('gao',1111.11);
SQLWKS>  insert into table3 values('zhu',5555.55);
SQLWKS> commit;

SQL> select avg(distinct sal) from gao.table3;

AVG(DISTINCTSAL)
----------------
         3333.33

SQL> select avg(all sal) from gao.table3;

AVG(ALLSAL)
-----------
    2592.59


61.MAX(DISTINCT|ALL)
求最大?ALL表示Ҏ有的值求最大?DISTINCT表示对不同的值求最大?相同的只取一?/font>
  q回选择列表目的最大|如果x是字W串数据cdQ他q回一个VARCHAR2数据cdQ如果X是一个DATA数据cdQ返回一个日期,如果X是numeric数据cdQ返回一个数字。注意distinct和all不v作用Q应为最大gq两U设|是相同的?br />
SQL> select max(distinct sal) from scott.emp;

MAX(DISTINCTSAL)
----------------
            5000


62.MIN(DISTINCT|ALL)
求最?ALL表示Ҏ有的值求最?DISTINCT表示对不同的值求最?相同的只取一?br />SQL> select min(all sal) from gao.table3;

MIN(ALLSAL)
-----------
    1111.11


63.STDDEV(distinct|all)
求标准差,ALL表示Ҏ有的值求标准?DISTINCT表示只对不同的值求标准?br />SQL> select stddev(sal) from scott.emp;

STDDEV(SAL)
-----------
  1182.5032

SQL> select stddev(distinct sal) from scott.emp;

STDDEV(DISTINCTSAL)
-------------------
           1229.951

 

64.VARIANCE(DISTINCT|ALL)
求协方差

SQL> select variance(sal) from scott.emp;

VARIANCE(SAL)
-------------
    1398313.9


65.GROUP BY
主要用来对一l数q行l计
SQL> select deptno,count(*),sum(sal) from scott.emp group by deptno;

   DEPTNO  COUNT(*)  SUM(SAL)
--------- --------- ---------
       10         3      8750
       20         5     10875
       30         6      9400

 

66.HAVING
对分l统计再加限制条?br />SQL> select deptno,count(*),sum(sal) from scott.emp group by deptno having count(*)>=5;

   DEPTNO  COUNT(*)  SUM(SAL)
--------- --------- ---------
       20         5     10875
       30         6      9400
SQL> select deptno,count(*),sum(sal) from scott.emp having count(*)>=5 group by deptno ;

   DEPTNO  COUNT(*)  SUM(SAL)
--------- --------- ---------
       20         5     10875
       30         6      9400


67.ORDER BY
用于Ҏ询到的结果进行排序输?br />SQL> select deptno,ename,sal from scott.emp order by deptno,sal desc;

   DEPTNO ENAME            SAL
--------- ---------- ---------
       10 KING            5000
       10 CLARK           2450
       10 MILLER          1300
       20 SCOTT           3000
       20 FORD            3000
       20 JONES           2975
       20 ADAMS           1100
       20 SMITH            800
       30 BLAKE           2850
       30 ALLEN           1600
       30 TURNER          1500
       30 WARD            1250
       30 MARTIN          1250
       30 JAMES            950



joeyeezhang 2006-11-04 19:16 发表评论
]]>
JNDI settinghttp://www.aygfsteel.com/joeyeezhang/archive/2006/01/09/27250.htmljoeyeezhangjoeyeezhangMon, 09 Jan 2006 05:39:00 GMThttp://www.aygfsteel.com/joeyeezhang/archive/2006/01/09/27250.htmlhttp://www.aygfsteel.com/joeyeezhang/comments/27250.htmlhttp://www.aygfsteel.com/joeyeezhang/archive/2006/01/09/27250.html#Feedback0http://www.aygfsteel.com/joeyeezhang/comments/commentRss/27250.htmlhttp://www.aygfsteel.com/joeyeezhang/services/trackbacks/27250.html 
           <Resource auth="Container" name="jdbc/javadb" type="javax.sql.DataSource"/>
     <ResourceParams name="jdbc/javadb">
       <parameter>
         <name>factory</name>
         <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
       </parameter>
       <parameter>
         <name>url</name>
         <value>jdbc:microsoft:sqlserver://jasonywf:1433;DatabaseName=oceansoftoa</value>
       </parameter>
       <parameter>
         <name>password</name>
         <value></value>
       </parameter>
       <parameter>
         <name>maxWait</name>
         <value>10000</value>
       </parameter>
       <parameter>
         <name>maxActive</name>
         <value>100</value>
       </parameter>
       <parameter>
         <name>driverClassName</name>
         <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
       </parameter>
       <parameter>
         <name>username</name>
         <value>sa</value>
       </parameter>
       <parameter>
         <name>maxIdle</name>
         <value>30</value>
       </parameter>
     </ResourceParams>
 
 </Context>

joeyeezhang 2006-01-09 13:39 发表评论
]]>
About database Url settinghttp://www.aygfsteel.com/joeyeezhang/archive/2006/01/09/27249.htmljoeyeezhangjoeyeezhangMon, 09 Jan 2006 05:33:00 GMThttp://www.aygfsteel.com/joeyeezhang/archive/2006/01/09/27249.htmlhttp://www.aygfsteel.com/joeyeezhang/comments/27249.htmlhttp://www.aygfsteel.com/joeyeezhang/archive/2006/01/09/27249.html#Feedback0http://www.aygfsteel.com/joeyeezhang/comments/commentRss/27249.htmlhttp://www.aygfsteel.com/joeyeezhang/services/trackbacks/27249.htmlmysql
drivers=org.gjt.mm.mysql.Driver
logfile=\doc\\lo.txt

mysql.url=jdbc:mysql://localhost/数据库名?useUnicode=true&characterEncoding=8859_1
mysql.maxconn=5
mysql.user=
mysql.password=
mysql.driver=org.gjt.mm.mysql.Driver
mysql.url=jdbc:mysql://218.197.19.113/study?useUnicode=true&characterEncoding=GBK


Oracle
drivers = oracle.jdbc.driver.OracleDriver
url = jdbc:oracle:thin:@localhost:1521:orcl
DB2
drivers = com.ibm.db2.jdbc.app.DB2Driver
url = jdbc:db2://localhost:5000/sample

Informix
drivers = com.informix.jdbc.IfxDriver
url = jdbc:informix-sqli://123.45.67.89:1533/testDB:INFORMIXSERVER=myserver;
user=testuser;password=testpassword


Sql Server7.0/2000
drivers = com.microsoft.jdbc.sqlserver.SQLServerDriver
drivers = sun.jdbc.odbc.JdbcOdbcDriver
url = jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs
url = jdbc:odbc:driver={SQL Server};server=zhl;Database=school

Access
drivers = sun.jdbc.odbc.JdbcOdbcDriver
url = jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\projects\\demo.mdb

for example:

Q?@ page contentType="text/html;charset=gb2312"%Q?
Q?@ page import="java.sql.*"%Q?
QhtmlQ?
QbodyQ?
Q?Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl";
//orclZ的数据库的SID
String user="scott";
String password="tiger";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from test";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%Q?
您的W一个字D内容ؓQ<%=rs.getString(1)%Q?
您的W二个字D内容ؓQ<%=rs.getString(2)%Q?
Q?}%Q?
Q?out.print("数据库操作成功,恭喜?);%Q?
Q?rs.close();
stmt.close();
conn.close();
%Q?
Q?bodyQ?
Q?htmlQ?

 



joeyeezhang 2006-01-09 13:33 发表评论
]]>
The sql statement of geting data about table config in SQL Serverhttp://www.aygfsteel.com/joeyeezhang/archive/2006/01/06/26881.htmljoeyeezhangjoeyeezhangFri, 06 Jan 2006 06:46:00 GMThttp://www.aygfsteel.com/joeyeezhang/archive/2006/01/06/26881.htmlhttp://www.aygfsteel.com/joeyeezhang/comments/26881.htmlhttp://www.aygfsteel.com/joeyeezhang/archive/2006/01/06/26881.html#Feedback0http://www.aygfsteel.com/joeyeezhang/comments/commentRss/26881.htmlhttp://www.aygfsteel.com/joeyeezhang/services/trackbacks/26881.html
  • select table_name from INFORMATION_SCHEMA.TABLES

  • SELECT dbo.syscolumns.name, dbo.syscolumns.colid AS columnID,dbo.sysobjects.ID AS TableID, dbo.systypes.name as DataType,case when dbo.syscolumns.autoval is not null then 1 else 0 end isautoval,  dbo.syscolumns.prec ,dbo.syscolumns.isnullable ,dbo.syscolumns.scale,dbo.sysproperties.[value] AS Description FROM   dbo.systypes RIGHT OUTER JOIN dbo.syscolumns ON dbo.systypes.xtype = dbo.syscolumns.xtype LEFT OUTER JOIN dbo.sysproperties ON dbo.syscolumns.id = dbo.sysproperties.id AND dbo.syscolumns.colid = dbo.sysproperties.smallid RIGHT OUTER JOIN  dbo.sysobjects ON dbo.syscolumns.id = dbo.sysobjects.id WHERE systypes.xtype = systypes.xusertype and (dbo.sysobjects.xtype = 'u') AND (dbo.systypes.status <> 1) AND (dbo.sysobjects.id <> 1977058079) and dbo.sysobjects.name='hr_users' order by dbo.syscolumns.colid

  • SELECT  dbo.syscolumns.name as name, dbo.sysproperties.[value] AS Description FROM   dbo.syscolumns LEFT OUTER JOIN dbo.sysproperties ON dbo.syscolumns.id = dbo.sysproperties.id AND dbo.syscolumns.colid = bo.sysproperties.smallid RIGHT OUTER JOIN dbo.sysobjects ON dbo.syscolumns.id = dbo.sysobjects.id WHERE (dbo.sysobjects.xtype = 'u') AND (dbo.sysobjects.id <> 1977058079) and dbo.sysobjects.name='hr_users'

     

     



  • joeyeezhang 2006-01-06 14:46 发表评论
    ]]>
    վ֩ģ壺 ֯| | ϴ| ƫ| | | | ȫ| | ɽ| | ɽ| ǰ| ̨| ϳ| | | ʱ| | | Զ| ױ| Ĭ| | | | | | | | | | | | | | ƽ| ½| | | |