- 浏览: 241874 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
nodonkey:
貌似还是不行,再等等吧,amfphp要出2.0了
amfphp1.9与php5.3.X版本不兼容 -
live711:
请问amfphp与php5.3.X搭配能用了吗?
amfphp1.9与php5.3.X版本不兼容 -
zhousheng193:
非常感谢!
安装flash player debug版本遇到的一些问题 -
sp42:
谢谢提示,我遇到的也是不能加密,用MAC地址代替之。
DI-624+A路由器韧体升级解决经常掉线的问题(转) -
心似海:
不错,要挖去了,哈哈
深入sql之merge into
TRUNCATE
Caution: You cannot roll back aTRUNCATE
statement. |
Purpose
Use the TRUNCATE
statement to remove all rows from a table or cluster. By default,
Oracle Database also deallocates all space used by the removed rows
except that specified by the MINEXTENTS
storage parameter and sets the NEXT
storage parameter to the size of the last extent removed from the segment by the truncation process.
Removing rows with the TRUNCATE
statement can be more
efficient than dropping and re-creating a table. Dropping and
re-creating a table invalidates dependent objects of the table,
requires you to regrant object privileges on the table, and requires
you to re-create the indexes, integrity constraints, and triggers on
the table and respecify its storage parameters. Truncating has none of
these effects.
See Also:
|
Prerequisites
To truncate a table or cluster, the table or cluster must be in your schema or you must have DROP
ANY
TABLE
system privilege.
Syntax
truncate::=
Description of the illustration truncate.gif
Semantics
Specify the schema and name of the table to be truncated. This table cannot be part of a cluster. If you omit schema
, then Oracle Database assumes the table is in your own cluster.
-
You can truncate index-organized tables and temporary tables. When you truncate a temporary table, only the rows created during the current session are removed.
-
Oracle Database changes the
NEXT
storage parameter oftable
to be the size of the last extent deleted from the segment in the process of truncation. -
Oracle Database also automatically truncates and resets any existing
UNUSABLE
indicators for the following indexes ontable
: range and hash partitions of local indexes and subpartitions of local indexes. -
If
table
is not empty, then the database marksUNUSABLE
all nonpartitioned indexes and all partitions of global partitioned indexes on the table. -
For a domain index, this statement invokes the appropriate truncate routine to truncate the domain index data.
-
If a regular or index-organized table contains LOB columns, then all LOB data and LOB index segments are truncated.
-
If
table
is partitioned, then all partitions or subpartitions, as well as the LOB data and LOB index segments for each partition or subpartition, are truncated.
Note:
When you truncate a table, Oracle Database automatically removes all data in the table's indexes and any materialized view direct-pathINSERT
information held in association with the table. This information is independent of any materialized view log. If this direct-pathINSERT
information is removed, then an incremental refresh of the materialized view may lose data.
-
You cannot individually truncate a table that is part of a cluster. You must either truncate the cluster, delete all rows from the table, or drop and re-create the table.
-
You cannot truncate the parent table of an enabled referential integrity constraint. You must disable the constraint before truncating the table. An exception is that you can truncate the table if the integrity constraint is self-referential.
-
If a domain index is defined on
table
, then neither the index nor any index partitions can be markedIN_PROGRESS
.
MATERIALIZED VIEW LOG Clause
The MATERIALIZED
VIEW
LOG
clause lets you specify whether a materialized view log defined on the
table is to be preserved or purged when the table is truncated. This
clause permits materialized view master tables to be reorganized
through export or import without affecting the ability of primary key
materialized views defined on the master to be fast refreshed. To
support continued fast refresh of primary key materialized views, the
materialized view log must record primary key information.
Note: The keywordSNAPSHOT
is supported in place of MATERIALIZED
VIEW
for backward compatibility. |
PRESERVE
Specify PRESERVE
if any materialized view log should be preserved when the master table is truncated. This is the default.
PURGE
Specify PURGE
if any materialized view log should be purged when the master table is truncated.
See Also: Oracle Database Advanced Replication for more information about materialized view logs and theTRUNCATE
statement |
Specify the schema and name of the cluster to be truncated. You can
truncate only an indexed cluster, not a hash cluster. If you omit schema
, then the database assumes the cluster is in your own schema.
When you truncate a cluster, the database also automatically deletes all data in the indexes of the cluster tables.
STORAGE Clauses
The STORAGE
clauses let you determine what happens to the space freed by the truncated rows. The DROP
STORAGE
clause and REUSE
STORAGE
clause also apply to the space freed by the data deleted from associated indexes.
DROP STORAGE
Specify DROP
STORAGE
to deallocate all space from the deleted rows from the table or cluster except the space allocated by the MINEXTENTS
parameter of the table or cluster. This space can subsequently be used
by other objects in the tablespace. Oracle Database also sets the NEXT
storage parameter to the size of the last extent removed from the segment in the truncation process. This is the default.
REUSE STORAGE
Specify REUSE
STORAGE
to retain the space
from the deleted rows allocated to the table or cluster. Storage values
are not reset to the values when the table or cluster was created. This
space can subsequently be used only by new data in the table or cluster
resulting from insert or update operations. This clause leaves storage
parameters at their current settings.
If you have specified more than one free list for the object you are truncating, then the REUSE
STORAGE
clause also removes any mapping of free lists to instances and resets the high-water mark to the beginning of the first extent.
Examples
Truncating a Table: Example
The following statement removes all rows from a hypothetical copy of the sample table hr.employees
and returns the freed space to the tablespace containing employees
:
TRUNCATE TABLE employees_demo;
The preceding statement also removes all data from all indexes on employees
and returns the freed space to the tablespaces containing them.
Retaining Free Space After Truncate: Example
The following statement removes all rows from all tables in the personnel
cluster, but leaves the freed space allocated to the tables:
TRUNCATE CLUSTER personnel REUSE STORAGE;
The preceding statement also removes all data from all indexes on the tables in the personnel
cluster.
Preserving Materialized View Logs After Truncate: Example
The following statements are examples of truncate statements that preserve materialized view logs:
TRUNCATE TABLE sales_demo PRESERVE MATERIALIZED VIEW LOG; TRUNCATE TABLE orders_demo;
发表评论
-
alter table move 与shrink space的区别
2012-03-06 13:51 2177转自:http://hi.baidu.co ... -
mysqlsla来分析MYSQL的性能及索引
2011-01-17 19:56 1263— Slow log: mysqlsla -lt slow ... -
六款常用mysql slow log分析工具的比较
2011-01-17 19:06 1236转自:http://www.iteye.com/topi ... -
MySQL的大小写敏感性
2011-01-12 14:05 1017转自: http://www.zeali.net/ent ... -
如何查看mysql的版本
2010-05-22 11:52 21977如果我们想要查看mysql数据库的版本有以下四种方法: ... -
MySQL 数据库的备份和恢复
2010-03-19 13:44 891转自 忧里修斯 http://tec ... -
mysql使用show命令以及replace函数批量修改数据
2010-03-19 13:37 2363一.mysql的show命令 a. show tables或 ... -
MySQL中的ROWNUM的实现
2010-01-26 13:43 2157本文转自 http://blog.csdn.net/ACMA ... -
一个MySQL死锁问题的分析及解决
2010-01-20 12:50 1222转自http://java-guru.iteye.com/bl ... -
MySQL 死锁分析
2010-01-20 12:42 32931.MySQL锁和死锁的理解: ... -
sql 按指定顺序排序
2010-01-19 10:53 21261、在ORACLE中使用Decode Decode实 ... -
MYSQL 事务管理
2009-10-26 19:48 1024mysql_query("BEGIN"); ... -
delete 符合条件的记录中的前几条或者重复记录
2009-09-03 20:04 2019今天写代码,遇到了这个问题,只能删除符合条件的记录中的某几条. ... -
sql update delete 中 使用 inner join
2009-08-24 11:38 7144SQL中使用update inner join和delet ... -
What is the difference between VARCHAR, VARCHAR2 ?
2009-06-01 09:43 899Both CHAR and VARCHAR2 types ar ... -
Oracle index
2009-05-15 10:50 0索引是一种可以提高查 ... -
Views and Materialized Views 整理
2009-04-10 14:29 1106Views and Mat ... -
IN and EXISTS, NOT IN AND NOT EXISTS
2009-04-10 14:28 1389Functionally, they are the same ... -
深入sql之merge into
2009-01-08 16:38 4696转自 逆水流沙 http://hi.baidu.com/wen ... -
Oracle日期函数操作(收集整理版)
2008-12-04 16:50 2749经常在平时的开发中要用到oracle的日期函数,每次都要上 ...
相关推荐
NULL 博文链接:https://steve-111.iteye.com/blog/750326
主要介绍了Oracle给用户授权truncatetable的实现方案,非常不错,具有参考借鉴价值,需要的朋友可以参考下
Oracle_审计表_sys.aud$_授权给用户Truncate权限
PRM DUL for oracle恢复被truncate截断掉的表 Oracle DBA神器:PRM灾难恢复工具,Schema级别数据恢复。PRM For Oracle Database – schema级别oracle数据库数据恢复特性 ,PRM即ParnassusData Recovery Manager是...
1.delete不能使自动编号返回为起始值。... 您可能感兴趣的文章:Oracle给用户授权truncatetable的实现方案SQL中Truncate的用法golang实战之truncate日志文件详解tf.truncated_normal与tf.random_normal
SQL> truncate table DB_JJ_INFO_TEMP; 2. 我们OFFLINE掉DB_JJ_INFO_TEMP表的表空间(实际上在实际的系统中,如果有比较多的活动,则表空间不容易被OFFLINE下来)。然后做一个Checkpoint,让ODU能够读到最新的数据...
利用oracle 系统触发器防止用户使用drop table 或truncate table 命令。
这次,我们主要讨论一下Oracle触发器在实际工作中的应用。同时借组SqlDevelop工具分享一下编写触发器过程的调式技巧(之前一编译就出现编译警告就无从下手)。当然,我还是初次接触调试,方法虽不尽人意,但是也不失...
索引与约束 ...truncate table plan_table; explain plan for select ename,job,sal from empcon where ename like ‘PRE%’; Select id,operation,options,object_name,position from plan_table;
首先要停止数据库, 将这个表所在的表空间的文件拷贝出来, 因为Oracle在Truncate只时将相应Segment的第一个块格式化掉了, 而后面的都还存在, 到下次用时到才真正地重新格式化. 下面来讲一个Truncate表后进行恢复的...
Truncate Table语句会将整个表中的所有数据删除。但删除的方式并不是一行一行的删除,而是将组成表的数据页释放,将组成表的相关页释放的操作交给一个后台的线程进行队列处理的过程被称为deferred-drop。使用后台...
”这一句不然其他的session无法drop(TRUNCATE TABLE 表名 必须在 ‘drop table 表名’ 这一句前执行) create or replace procedure p_DevData(p_id IN varchar2(150),pageIndex in NUMBER,pageC
ORACLE的数据字典是数据库的重要组成部分之一,它随着数据库的产生而产生, 随着数据库的变化而变化, 体现为sys用户下的一些表和视图。数据字典名称是大写的英文字符。 数据字典里存有用户信息、用户的权限信息、...
ORACLE数据库系统是美国ORACLE公司(甲骨文)提供的以分布式数据库为核心的一组软件产品,是目前最流行的客户/服务器(CLIENT/SERVER)或B/S体系结构的数据库之一。 拉里•埃里森 就业前景 从就业与择业的...
4. 解释data block , extent 和 segment的区别(这里建议用英文术语) ... fact table 包含大量的主要的信息而 dimension tables 存放对fact table 某些属性描述的信息 10. FACT Table上需要建立何种索引?
1.什么是ORACLE锁 数据库是一个多用户使用的共享... 6 X(Exclusive) 排它锁 Alter table、Drop able、Drop index、Truncate table 、Lock exclusive Oracle举例 欢迎登陆交流 程序员百味: http://www.bywei.cn/blog
使用Truncate替代delete来删除记录,但Truncate数据不记录日志,无法进行回滚 对于复杂的存储过程可以多次提交的数据的要多分多次Commit,否则长事务对系统性能影响很大 Distinct和Having子句都是耗时操作,...
oracle_PLSQL_语法详细手册 目 录 第一部分 SQL语法部分 3 一、 CREATE TABLE 语句 3 二、 CREATE SEQUENCE语句 5 三、 CREATE VIEW语句 6 四、 INSERT语句: 7 五、 UPDATE语句: 9 六、 DELETE语句: 10 七、 ...