SHRINK SPACE CHECK

利用SHRINK SPACE可以更好的对segment进行管理。但SHRINK SPACE功能在oracle的不同版本中也略有差异。

其实我们可以不用记住不同版本中SHRINK SPACE的限制条件。

因为oracle提供了‘ALTER TABLE ... SHRINK SPACE CHECK’的功能。

参考:What is the Meaning of SHRINK SPACE CHECK? [ID 1132163.1]

The "ALTER TABLE ... SHRINK SPACE CHECK" statement is used to to properly check for proper
segment type and segment attributes (e.g. row movement enabled) to allow shrink.
The statement performs the exact same verifications as the "ALTER TABLE ... SHRINK SPACE",
but it does not perform any actual shrinking on the segment.

用法:
SQL> alter table dept shrink space check;
alter table dept shrink space check
*
第 1 行出现错误:
ORA-10636: ROW MOVEMENT is not enabled


SQL> alter table dept enable row movement;

表已更改。

SQL> alter table dept shrink space check;
alter table dept shrink space check
*
第 1 行出现错误:
ORA-10655: Segment can be shrunk

这其实不是个错误,而是告诉我们这个段可以进行shrink操作。

This is not an error message, but rather a confirmation message about the possibility of shrinking the segment

 

 

关于SEGMENT SHRINK在ORACLE不同版本中的限制条件:
参考:SEGMENT SHRINK and details. [ID 242090.1]
Restrictions on the shrink_clause, 10gR1
========================================
1. You cannot specify this clause for a cluster, a clustered table, or any
   object with a LONG column.
2. Segment shrink is not supported for LOB segments even if CASCADE is
   specified.
3. Segment shrink is not supported for tables with function-based indexes.
4. This clause does not shrink mapping tables or overflow segments of
   index-organized tables, even if you specify CASCADE.
5. You cannot shrink a table that is the master table of an ON COMMIT
   materialized view. Rowid materialized views must be rebuilt after the
   shrink operation.
6. Table with a domain index is not supported.

Restrictions on the shrink_clause, 10gR2
========================================
1. You cannot specify this clause for a cluster, a clustered table, or any
   object with a LONG column.
2. Segment shrink is not supported for tables with function-based indexes or
   bitmap join indexes.
3. This clause does not shrink mapping tables of index-organized tables,
   even if you specify CASCADE.
4. You cannot specify this clause for a compressed table.
5. You cannot shrink a table that is the master table of an ON COMMIT
   materialized view. Rowid materialized views must be rebuilt after the
   shrink operation.
6. Table with a domain index is not supported.

Restrictions on the shrink_clause, 11gR1
========================================
1. You cannot combine this clause with any other clauses in the same ALTER TABLE
   statement.
2. You cannot specify this clause for a cluster, a clustered table, or any
   object with a LONG column.
3. Segment shrink is not supported for tables with function-based indexes or
   bitmap join indexes.
4. This clause does not shrink mapping tables of index-organized tables, even if
   you specify CASCADE.
5. You cannot specify this clause for a compressed table.
6. You cannot shrink a table that is the master table of an ON COMMIT
   materialized view. Rowid materialized views must be rebuilt after the shrink
   operation.

 


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
shrink spaceOracle数据库中的一个操作,用于减小表或分区的存储空间。根据引用\[1\]的建议,在生产环境下,可以采取两步操作来进行shrink space。第一步是执行"alter table table_name shrink space compact"命令,这个命令只执行了阶段一,可以在中间取消并在下次重新执行。第二步是执行"alter table table_name shrink space"命令,这个命令会降低表的高水位,建议在空闲时执行,一旦开始就不能取消,否则可能会遇到BUG或字典不一致的问题。\[1\] 另外,根据引用\[2\],可以使用以下SQL语句来生成shrink space的命令,以便对特定的表或分区进行操作:"select 'alter table '||owner||'.'||segment_name||' modify partition '||partition_name||' shrink space;'" 在shrink space过程中,根据引用\[3\],数据会在压缩阶段进行移动。在移动过程中,会对包含数据的行和/或块进行锁定,这会导致并发的DML操作(如更新和删除)在锁上串行执行。压缩操作将以较小的事务单位进行,因此对象的可用性不会受到显著影响。 总结起来,shrink spaceOracle数据库中用于减小表或分区存储空间的操作。可以通过两步操作来执行,同时需要注意在适当的时机执行,并避免取消操作以避免潜在的问题。 #### 引用[.reference_title] - *1* *3* [shrink space的最佳实践](https://blog.csdn.net/cotchte0421/article/details/100377961)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [收缩表段(shrink space)](https://blog.csdn.net/lihuarongaini/article/details/101402020)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值