📄 539.html
字号:
<STYLE type=text/css>
<!--
body,td { font-size:9pt;}
hr { color: #000000; height: 1px}
-->
</STYLE>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD><TITLE>论坛精华 >> Oracle 专栏 >> Oracle数据库系统使用经验六则</title>
</head>
<body >
<p><IMG SRC="../image/jsp001_middle_logo.gif" WIDTH="180" HEIGHT="60" BORDER=0 ALT=""></p>
<table width=100% bgcolor="#cccccc" align=center cellpadding="2" cellspacing="0" border=1 bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr bgcolor="#EFF8FF"><td>
<a href=http://www.jsp001.com/list_thread.php?int_attribute=4>论坛精华</a>
>> <a href=http://www.jsp001.com/list_thread.php?forumid=20&int_attribute=4>Oracle 专栏</a>
>> Oracle数据库系统使用经验六则 [<a href=http://www.jsp001.com/forum/showthread.php?goto=newpost&threadid=539>查看别人的评论</a>]<br>
<hr><p>由 guest 发布于: 2001-02-26 12:43</p><p> </p><p> ---- 笔者的工作与Oracle数据库"息息相关",在实践中学习和摸索了一些小经验,在此与大家共同探讨. <br><br><br>---- 1.having 子句的用法 <br><br><br>---- having 子句对 group by 子句所确定的行组进行控制,having 子句条件中只允许涉及常量,聚组函数或group by 子句中的列. <br><br><br>---- 2.外部联接"+"的用法 <br><br><br>---- 外部联接"+"按其在"="的左边或右边分左联接和右联接.若不带"+"运算符的表中的一个行不直接匹配于带"+"预算符的表中的任何行,则前者的行与后者中的一个空行相匹配并被返回.若二者均不带’+’,则二者中无法匹配的均被返回.利用外部联接"+",可以替代效率十分低下的 not in 运算,大大提高运行速度.例如,下面这条命令执行起来很慢 <br><br><br>select a.empno from emp a where a.empno not in <br><br>(select empno from emp1 where job=’SALE’); <br><br><br>---- 倘若利用外部联接,改写命令如下: <br><br><br>select a.empno from emp a ,emp1 b <br><br>where a.empno=b.empno(+) <br><br>and b.empno is null <br><br>and b.job=’SALE’; <br><br><br>---- 可以发现,运行速度明显提高. <br><br><br>---- 3.删除表内重复记录的方法 <br><br><br>---- 可以利用这样的命令来删除表内重复记录: <br><br><br>delete from table_name a <br><br>where rowid< (select max(rowid) from table_name <br><br>where column1=a.column1 and column2=a.column2 <br><br>and colum3=a.colum3 and ...); <br><br><br>---- 不过,当表比较大(例如50万条以上)时,这个方法的效率之差令人无法忍受,需要另想办法(可参看拙文《电信计费中长途重复话单的技术处理》,《计算机与通信》,1999-07). <br><br><br>---- 4.set transaction 命令的用法 <br><br><br>---- 在执行大事务时,有时oracle会报出如下的错误: <br><br><br>ORA-01555:snapshot too old (rollback segment too small) <br><br><br>---- 这说明oracle给此事务随机分配的回滚段太小了,这时可以为它指定一个足够大的回滚段,以确保这个事务的成功执行.例如 <br><br><br>set transaction use rollback segment roll_abc; <br><br>delete from table_name where ... <br><br>commit; <br><br><br>---- 回滚段roll_abc被指定给这个delete事务,commit命令则在事务结束之后取消了回滚段的指定. <br><br><br>---- 5.使用索引的注意事项 <br><br><br>---- select,update,delete 语句中的子查询应当有规律地查找少于20%的表行.如果一个语句查找的行数超过总行数的20%,它将不能通过使用索引获得性能上的提高. <br><br><br>---- 索引可能产生碎片,因为记录从表中删除时,相应也从表的索引中删除.表释放的空间可以再用,而索引释放的空间却不能再用.频繁进行删除操作的被索引的表,应当阶段性地重建索引,以避免在索引中造成空间碎片,影响性能.在许可的条件下,也可以阶段性地truncate表,truncate命令删除表中所有记录,也删除索引碎片. <br><br><br>---- 6.数据库重建应注意的问题 <br><br><br>---- 在利用import进行数据库重建过程中,有些视图可能会带来问题,因为结构输入的顺序可能造成视图的输入先于它低层次表的输入,这样建立视图就会失败.要解决这一问题,可采取分两步走的方法:首先输入结构,然后输入数据.命令举例如下 (uesrname:jfcl,password:hfjf,host sting:ora1,数据文件:expdata.dmp): <br><br><br>imp jfcl/hfjf@ora1 file=empdata.dmp rows=N <br><br>imp jfcl/hfjf@ora1 file=empdata.dmp full=Y buffer=64000 <br><br>commit=Y ignore=Y <br><br><br>---- 第一条命令输入所有数据库结构,但无记录.第二次输入结构和数据,64000字节提交一次.ignore=Y选项保证第二次输入既使对象存在的情况下也能成功. <br><br>__________________<br>我就是我,命运由我摆布。</p></td>
</tr>
</table>
<p>
<CENTER><a href="http://www.jsp001.com/forum/newreply.php?action=newreply&threadid=539">点这里对该文章发表评论</a></CENTER>
<p>该文章总得分是 <font color=red>6</font> 分,你认为它对你有帮助吗?
[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=539&intVote=4","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>非常多</a>](<font color=red>1</font>)
[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=539&intVote=2","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>有一些</a>](<font color=red>1</font>)
[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=539&intVote=1","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>无帮助</a>](<font color=red>1</font>)
[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=539&intVote=-1","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>是灌水</a>](<font color=red>1</font>) </p>
<script language="javascript" src="http://www.jsp001.com/include/read_thread_script.php?threadid=539"></script>
<p><CENTER>
Copyright © 2001 - 2009 JSP001.com . All Rights Reserved <P>
<IMG SRC="../image/jsp001_small_logo.gif" WIDTH="85" HEIGHT="30" BORDER=0 ALT="">
</CENTER></p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -