SQL 一旦表被删除,索引会发生什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8433011/
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
What happens to index once the table got dropped?
提问by Vaandu
After dropping the table, found that the index created on the columns of the dropped table is gone. I just want to know what happens after that. Could someone please explain?
删除表后,发现删除表的列上创建的索引没有了。我只想知道在那之后会发生什么。有人可以解释一下吗?
What all are the others getting dropped along with table drop?
除了桌子掉落,其他人都掉落了什么?
回答by Raihan
In Oracle when dropping a table
在 Oracle 中删除表时
- all table indexes and domain indexes are dropped
- any triggers defined on the table are dropped
- if table is partitioned, any corresponding local index partitions are dropped
- if the table is a base table for a view or if it is referenced in a stored procedure, function, or package, then these dependent objects are invalidated but not dropped
- 删除所有表索引和域索引
- 表上定义的任何触发器都将被删除
- 如果表已分区,则删除任何相应的本地索引分区
- 如果该表是视图的基表,或者它在存储过程、函数或包中被引用,则这些依赖对象将失效但不会被删除
回答by Magnus H
MySQL also drops table indexes when tables are dropped.
当表被删除时,MySQL 也会删除表索引。
For more info, see Does dropping a table in MySQL also drop the indexes?
有关更多信息,请参阅在 MySQL 中删除表是否也会删除索引?
回答by Merijn Vogel
By default, MS Sql Server also drops indexes when a table is dropped. (Observed in version 13.0.4206.0.)
默认情况下,MS Sql Server 也会在删除表时删除索引。(在版本 13.0.4206.0 中观察到。)
回答by Atty
In Postgres
在 Postgres 中
DROP TABLE always removes -
1. any indexes
2. rules
3. triggers
4. constraints
that exist for the target table.