在现有表 Oracle 上创建索引
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7009227/
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
Create index on existing table Oracle
提问by Michael
Is it safe to create an index on an existing table in oracle?
在 oracle 中的现有表上创建索引是否安全?
Like this:
像这样:
CREATE INDEX table_sample_ix03
ON table_sample
(
col4,
col22
)
TABLESPACE data
STORAGE
(
INITIAL 10M NEXT 2M
MINEXTENTS 1 MAXEXTENTS 100
PCTINCREASE 0
)
;
回答by Pierluigi Vernetto
The ONLINE clause is recommended when you create the index while DML queries are being run on the table. See http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_5010.htm
当您在表上运行 DML 查询时创建索引时,建议使用 ONLINE 子句。请参阅http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_5010.htm
Example:
例子:
CREATE INDEX "MYINDEX" ON "MYTABLE" ("MYCOLUMN") ONLINE;
回答by Thilo
Yes. But if possible, you should do it while no one is updating the table, because they would suffer performance-wise (it is still safe to do it anyway, there will be no data corruption).
是的。但是如果可能的话,您应该在没有人更新表的情况下执行此操作,因为它们会在性能方面受到影响(无论如何这样做仍然是安全的,不会有数据损坏)。
回答by deltaforce2
Yes. Why wouldn't it be?
是的。为什么不会呢?
I can only think of possible performance issues just after issuing the command. If the table is very large, the indexing can take some time but other than that, it should be fine.
我只能在发出命令后才想到可能的性能问题。如果表非常大,索引可能需要一些时间,但除此之外,应该没问题。