在 oracle 11g 中缩小数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10934037/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
shrink a database in oracle 11g
提问by samar
I am not a database administrator by any means so I might be wrong in stating some of the things here.
我无论如何都不是数据库管理员,所以我在这里陈述的一些事情可能是错误的。
In SQL Server, when we add a large amount of data in the database and then when we delete it, the size of the data files (.mdf file) or database (or whatever it is called) does not get reduced to the original size. We need to shrink it.
在 SQL Server 中,当我们在数据库中添加大量数据然后删除它时,数据文件(.mdf 文件)或数据库(或其他任何名称)的大小不会减小到原始大小. 我们需要缩小它。
Do the same fundamentals work in Oracle? If yes then how should I go about shrinking an Oracle 11g database?
相同的基本原理在 Oracle 中是否有效?如果是,那么我应该如何缩小 Oracle 11g 数据库?
回答by xelco52
Full explanation from the Oracle Documentation: Reclaiming Wasted Space. For the short version:
Oracle 文档中的完整解释:回收浪费的空间。对于简短版本:
"You can shrink space in a table, index-organized table, index, partition, subpartition, materialized view, or materialized view log. You do this using ALTER TABLE, ALTER INDEX, ALTER MATERIALIZED VIEW, or ALTER MATERIALIZED VIEW LOG statement with the SHRINK SPACE clause."
“您可以缩小表、索引组织表、索引、分区、子分区、物化视图或物化视图日志中的空间。您可以使用 ALTER TABLE、ALTER INDEX、ALTER MATERIALIZED VIEW 或 ALTER MATERIALIZED VIEW LOG 语句执行此操作SHRINK SPACE 子句。”
So, after running the Oracle Segment Advisor to recommend areas to shrink, something like the following will shrink space in a table named mytable
.
因此,在运行 Oracle Segment Advisor 以推荐要缩小的区域后,类似以下内容将缩小名为 的表中的空间mytable
。
SQL> alter table mytable enable row movement;
Table altered
SQL> alter table mytable shrink space;
Table altered