Intentionally Cause ORA-00600 exception in Oracle

28.5k Views Asked by At

For testing purposes I need a couple of SQL scripts that will cause an ORA-00600 error in Oracle, version 11.1.0.7.

The database is not empty, it is filled with the data of a fresh install of Vision Demo E-Business Suite.

This system is a training ground for students studying Oracle. It will be used to develop their troubleshooting skills. Why SQL? Because this scripts reproduction should be automated. We will randomize the issue occurrence to create a model of a real bugging system for mastering troubleshooting activity.

What exactly I need is 4-5 different ways to cause ORA-00600 error.

Note: This question is not about explaining what an ORA-600 error is, or how to troubleshoot them. This question is about intentionally causing an ORA-600 error.

3

There are 3 best solutions below

1
On

As per here:

ORA-600 is an internal error generated by the generic kernel code of the Oracle RDBMS software. It is different from other Oracle errors in many ways. Possible causes include:

  • time-outs,
  • file corruption,
  • failed data checks in memory, hardware, memory, or I/O messages,
  • incorrectly restored files
  • a SELECT FROM DUAL statement in PL/SQL within Oracle Forms (you have to use SELECT FROM SYS.DUAL instead!)

So, in order to generate these errors, you probably need to cause some serious damage to your database, not something I'd advise. The last bullet point above may be a way to do it so I'd test that first.

3
On

You can't cause an ORA-00600 "naturally"; it's a generic exception that covers internal Oracle exceptions. So, unless you know of an Oracle bug that causes this or want to deliberately corrupt your database you've got no chance.

What you can do is raise an application error yourself, which can mimic that exception:

declare
   internal_exception EXCEPTION;
   PRAGMA EXCEPTION_INIT( internal_exception, -600 );
begin
  raise internal_exception;
end;
/
declare
*
ERROR at line 1:
ORA-00600: internal error code, arguments: [], [], [], [], [], [], [], [], [], [], [], []
ORA-06512: at line 5

If you have to do this from SQL you can convert the above into a function:

create or replace function raise_600 return number is
   internal_exception EXCEPTION;
   PRAGMA EXCEPTION_INIT( internal_exception, -600 );
begin
  raise internal_exception;
  return 1;
end;

Then just call it:

select raise_600 from dual
1
On

May be all toghether we can find good examples for you ...

Just to start a collection:

№1 (found here)

create table t(a clob);

insert into t values(utl_raw.cast_to_varchar2('EC'));

№2 Didn't return ORA-600 to client, just drops connection. But this error may be found in server logs. This case must be verified because I don't have access to test environment at the moment. Please, add a comment to indicate if such cases are interesting.

create table t1(id number);
create table t2(id number);

insert into t1(id) values(1);
insert into t1(id) values(2);
insert into t2(id) values(1);
insert into t2(id) values(2);

select 
  ta.id
from 
  t1 ta
  join (
    select id 
    from t2 
    start with id = 1 connect by prior id + 1= id 
  ) tb 
    on prior ta.id = tb.id
start with 
  ta.id = 2
connect by 
  prior ta.id - 1 = ta.id