<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TQ 试用 WP &#187; delete table</title>
	<atom:link href="http://tq.freehostia.com.freehostia.com/tag/delete-table/feed" rel="self" type="application/rss+xml" />
	<link>http://tq.freehostia.com.freehostia.com</link>
	<description>TQ 试用中... ...</description>
	<lastBuildDate>Fri, 19 Mar 2010 06:07:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Oracle truncate table 与 delete tabel的区别</title>
		<link>http://tq.freehostia.com.freehostia.com/2009/08/truncate-table-or-delete-table.html</link>
		<comments>http://tq.freehostia.com.freehostia.com/2009/08/truncate-table-or-delete-table.html#comments</comments>
		<pubDate>Tue, 11 Aug 2009 10:25:00 +0000</pubDate>
		<dc:creator>TQ</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[delete table]]></category>
		<category><![CDATA[truncate table]]></category>

		<guid isPermaLink="false">http://tq.freehostia.com.freehostia.com/2009/08/truncate-table-or-delete-table.html</guid>
		<description><![CDATA[一、
1.delete产生rollback，如果删除大数据量的表速度会很慢，同时会占用很多的rollback segments .truncate 是DDL操作，不产生rollback，速度快一些.　　Truncate table does not generate rollback information and redo re... ]]></description>
			<content:encoded><![CDATA[<p>一、
<p>1.delete产生rollback，如果删除大数据量的表速度会很慢，同时会占用很多的rollback segments .truncate 是DDL操作，不产生rollback，速度快一些.<br />　　Truncate table does not generate rollback information and redo records so it is much faster than delete.<br />　　In default, it deallocates all space except the space allocated by MINEXTENTS unless you specify REUSE STORAGE clause.<br />2.不从tablespace中腾出空间,需要<br />　　ALTER TABLESPACE AAA COALESCE; 才有空间<br />3.truncate 调整high water mark 而delete不.truncate之后，TABLE的HWM退回到 INITIAL和NEXT的位置（默认）<br />　　delete 则不可以。<br />4.truncate 只能对TABLE<br />　　delete 可以是table,view,synonym<br />5.TRUNCATE TABLE 的对象必须是本模式下的，或者有drop any table的权限 而 DELETE 则是对象必须是本模式下的，或被授予 DELETE ON SCHEMA.TABLE 或DELETE ANY TABLE的权限
<p>二、 truncate是DDL語言.<br />delete是DML語言<br />DDL語言是自動提交的.<br />命令完成就不可回滾.<br />truncate的速度也比delete要快得多. 所以，delete 后要commit work，而truncate就不需要啦。
<p>三、 truncate 会把 highwatermark 回归至 0 &#8230; 当下一次再插入新资料时就会快一些啦。<br />所以一般都是在 temp table 上使用的，不过要注意就是 truncate 不能在 pl/sql 上使用，要用 dynamic SQL 才可以。
<p>四、
<p>当你不再需要该表时， 用 drop;<br />当你仍要保留该表，但要删除所有记录时， 用 truncate;<br />当你要删除部分记录时（always with a WHERE clause), 用 delete.
<p>五、
<p>1.TRUNCATE TABLE
<p>Index也會刪掉不是指drop index<br />sys@DEMO&gt; create index </p>
]]></content:encoded>
			<wfw:commentRss>http://tq.freehostia.com.freehostia.com/2009/08/truncate-table-or-delete-table.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
