How do I check index building status on Oracle 11? - oracle

I made terrible mistake in SQL index creation:
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:
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.
Production system not working for 9 hours now and my boss wanna explode. :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).
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;

You should be able to view the progress of the operation in 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.

Related

How to get the history of Function in Oracle Database

I have created a Function in Oracle Database. Now by mistake, I have changed that function. I have removed a few things inside it. Is there any way to restore the old Function.
I have checked and found that there is a possibility to recover the Database table from Flashback command. But is there any way to recover the Function?
You might try a flashback query while connected as SYS:
select s.text
from dba_source as of timestamp timestamp '2018-07-31 00:00:00' s
where s.owner = 'YOURSCHEMA'
and s.name = 'YOURFUNCTION'
order by s.line;
You must be connected as SYS to do this, as DBA_OBJECTS is a view over internal system tables such as USER$, OBJ$, SOURCE$, X$JOXCD etc, which you won't have access to as a regular user.
This will typically let you go back a few minutes or hours, depending on your undo_retention setting (default is 15 minutes) and how much DML the instance is doing.

How to find the cause of sudden Undo TableSpace increase?

I use Oracle R12.1.3 on Oracle 10g DB 10.2.0.4 version hosted in IBM AIX 5.3 OS.
Recently I found the data occupied in Undo TableSpace was suddenly increased.
Please let me know what can be the cause of this sudden increase.
If there is a query to find this cause please let me know.
The below query will give the queries which were executed in last hour.
More rows_processed means more undo for DMLs.
select rows_processed, sql_id, sql_text from v$sql where last_active_time > sysdate-1/24 order by rows_processed desc;

Oracle performance drop in massive table copy

Situation:
I'm using Oracle 11g R2 to work on two database users.
User U0 = original database with hundreds of tables
User U1 = copy of U0 to be used for simulating U0
To maintain U1, I run a script as below on U1 when simulation starts.
truncate table T1;
truncate table T2;
...
insert into T1 (select * from U0.T1)
insert into T2 (select * from U0.T2)
...
Problem: It had no problem for few days, but got slower after weeks.
Also it sometimes stop inserting records in tables, and in this case it always stops at same table. However I don't think that the table size is the problem since it has less than 20,000 records only.
I guess that this is due to resource problem in DBMS side, disk or memory, but have no idea how to resolve it. I could find a similar question as below without exact procedure to work around storage problem. Maybe this can be simple one to DBAs but unfortunately I'm not qualified for that.
Oracle performance issue with massive inserts and truncates (AWR attached)
Edit: following Jon Heller's comment, I've got query results as follows.
dba_resumable : no records.
gv$sql : 5~6 records queried but insert statement is not included.
Most notable one is "select TIME_WAITED_MICRO from V$SYSTEM_EVENT where event = 'Shared IO Pool Memory'". I guess it is due to insufficient memory.
report_sql_monitor : every sql_id returns "SQL Monitoring Report" without additional information.
Edit2: Please forget about edit above. Insert statement appeared in gv$sql query and SQL monitor result is as attached picture.
Edit3: This time SQL monitor returned Activity detail for the same insert statement.

SAS connection to Oracle hung up for 2 hours

In SAS we have a library which is actually ORACLE schema and today I faced with a strange event when trying to query a table in this library.
A regular SAS SQL query:
proc sql;
delete from table where id=123;
quit;
Was hung up for two hours while it usually took some seconds:
NOTE: PROCEDURE SQL used (Total process time):
real time 2:00:33.49
cpu time 0.03 seconds
While this operation was being performed I tried to delete a nearby row in ORACLE SQL DEVELOPER but it hung up processing delete request too. However deleting a row that was not nearby these rows did not cause any problems. Well how can I find out the possible reason? I guess that was a sort of deadlock.
It sounds like someone has locked a row that your session is trying to delete. You should be able to spot this by querying v$session:
select sid, schemaname, osuser, terminal, program, event
from v$session
where type != 'BACKGROUND';
and checking if your session has an event of "enq: TX - row lock contention" (or similar). If so, then you'll have to work out who has the blocking lock (if you have access to Toad's session browser, this is easy to do, but Google should throw up something that can help. Or, if your database is Oracle 11.2, there's a view: v$session_blockers that ought to pinpoint the blocking session), and then get them to either commit or rollback their transaction.

Oracle 11gR2 MView refresh failing

Hi I have created 5 MViews for tables in Remote DB 2 days back in production environment. Out of that one Mview, at the time of creation it worked fine. But 2 days after(today) the MView's last refresh date is still showing the day before yesterday's date.
I checked on the DBA_JOBS:
LAST_DATE,NEXT_DATE,BROKEN,INTERVAL,FAILURES,WHAT
NULL,"23-JUL-13 01:00:00", N,"trunc(SYSDATE+1)+1/24",12,"dbms_refresh.refresh('"OCCSS_ENTMT_HK"."MV_SCI_STD_CODE_VALUE"');"
MView create statement:
CREATE MATERIALIZED VIEW MV_SCI_STD_CODE_VALUE BUILD IMMEDIATE USING INDEX REFRESH FORCE ON DEMAND START WITH SYSDATE+0 NEXT TRUNC(SYSDATE+1)+1/24 WITH PRIMARY KEY USING DEFAULT LOCAL ROLLBACK SEGMENT USING ENFORCED CONSTRAINTS DISABLE QUERY REWRITE AS SELECT STV_STD_CODE_NUM STANDARD_CODE,
STV_STD_CODE_VALUE STANDARD_CODE_VALUE,
STV_STD_CODE_VALUE_DESC DESCRIPTION,
stv_prnt_std_code_value parent_code FROM SCIADMIN.P03_STD_CODE_VALUE#SCI_LINK02.HK.BT.COM P03 WHERE STV_STD_CODE_NUM IN ('19','31','54','5','6','300') AND p03.update_status_ind <> 'D';
COMMENT ON MATERIALIZED VIEW MV_SCI_STD_CODE_VALUE IS 'snapshot table for snapshot MV_SCI_STD_CODE_VALUE';
The Mview is scheduled to run once in one day. But the failures shown is 12.
I couldn't find any jobs for the above in DBMS_JOBS_RUNNING.
I need to investigate this issue. What would be the possible issues which could have caused this failure?

Resources