当我删除一个列时,Oracle 会发生什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4067062/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 21:47:58  来源:igfitidea点击:

What happens in Oracle when I drop a column?

oracle

提问by trinity

What are the various things that happen when I drop a column from a filled table. In all_tab_columns, does the column_id of other columns get reset?

当我从填充的表格中删除一列时会发生哪些不同的事情。在 all_tab_columns 中,是否重置了其他列的 column_id?

回答by Jonathan Leffler

The actions will include at least the following:

行动将至少包括以下内容:

  • The data stored in that column is lost.
  • Views referencing that column are invalidated - but (according to Gary- thanks!) they're not dropped; they stay invalid until revised to work with the modified schema.
  • Stored procedures referencing that column are invalidated - same caveat.
  • The column ID numbers of following columns will be reset.
  • Permissions granted on the column will be removed.
  • Indexes referencing that column will be dropped.
  • 存储在该列中的数据丢失。
  • 引用该列的视图无效 - 但是(根据Gary- 谢谢!)它们没有被删除;在修改为使用修改后的架构之前,它们将保持无效。
  • 引用该列的存储过程无效 - 同样的警告。
  • 以下列的列 ID 编号将被重置。
  • 对该列授予的权限将被删除。
  • 引用该列的索引将被删除。

回答by Connor

alter table drop column

更改表删除列

will actually visit each block and remove the column data - and that's an expensive thing to do for a large table.

实际上会访问每个块并删除列数据 - 这对于大表来说是一件昂贵的事情。

You might find it more prudent to issue:

您可能会发现发出以下命令更为谨慎:

alter table set unused

更改表设置未使用

which just flags the column as "gone" in the dictionary. If you then still need to reclaim that space, you can schedule an "alter table drop unused" at a quiet time

它只是在字典中将该列标记为“消失”。如果您仍然需要回收该空间,您可以在安静的时间安​​排“更改表删除未使用”