如何在 Oracle 11 上检查索引构建状态?

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

How do I check index building status on Oracle 11?

oracleplsqloracle11gindexingplsqldeveloper

提问by WBAR

I made terrible mistake in SQL index creation:

我在 SQL 索引创建中犯了可怕的错误:

create index IDX_DATA_TABLE_CUSECO on DATA_TABLE (CUSTOMER_ID, SESSION_ID, CONTACT_ID)
  tablespace IDX_TABLESPACE LOCAL ;

As You can see I missed keyword "ONLINE" to create index without blocking PRODUCTION table with high usage with 600m+ records. Corrected SQL is:

正如您所看到的,我错过了关键字“ONLINE”来创建索引,而不会阻塞具有 600m+ 记录的高使用率的 PRODUCTION 表。更正的 SQL 是:

create index IDX_DATA_TABLE_CUSECO on DATA_TABLE (CUSTOMER_ID, SESSION_ID, CONTACT_ID)
  tablespace IDX_TABLESPACE LOCAL ONLINE;

I was done it under PL/SQL Developer. When I was trying to stop it program stop responding and crashed.

我是在 PL/SQL Developer 下完成的。当我试图停止它时,程序停止响应并崩溃。

Production system not working for 9 hours now and my boss wanna explode. :D

生产系统现在不能工作 9 个小时,我的老板想爆炸。:D

Is there any chance to see how many seconds/minutes/hours Oracle 11g left to process this index creation ? Or maybe is there any chance to see does Oracle still working on this request? (PL/SQL Developer crashed).

有没有机会看到 Oracle 11g 还剩下多少秒/分钟/小时来处理这个索引创建?或者是否有机会看到 Oracle 是否仍在处理此请求?(PL/SQL Developer 崩溃了)。

For haters: I know I should do this like mentioned here: (source)

对于仇恨者:我知道我应该像这里提到的那样做:(来源

CREATE INDEX cust_idx on customer(id) UNUSABLE LOCAL;
ALTER INDEX cust_idx REBUILD parallel 6 NOLOGGING ONLINE;


回答by Justin Cave

You should be able to view the progress of the operation in V$SESSION_LONGOPS

您应该能够在 V$SESSION_LONGOPS

SELECT sid, 
       serial#, 
       target, 
       target_desc, 
       sofar, 
       totalwork, 
       start_time, 
       time_remaining, 
       elapsed_seconds
  FROM v$session_longops
 WHERE time_remaining > 0

Of course, in a production system, I probably would have killed the session hours ago rather than letting the DDL operation continue to prevent users from accessing the application.

当然,在生产系统中,我可能会在几个小时前终止会话,而不是让 DDL 操作继续阻止用户访问应用程序。