Why you should never create own objects under SYS

I got many times the request by developers to create objects under the SYS schema and my comment is normally "NO". Here is a nice showcase, why the creation of own objects under the SYS schema can become really dangerous:

conn / as sysdba
select count(*) from dba_objects where status = 'INVALID';
COUNT(*)
----------------
        0
-- Now lets create a simple table named SYSTEM under the SYS schema
create table SYS.SYSTEM (id number);
Table created.
-- Now check for invalid objects again.
-- Note: I didnt do anything special after the creation of the table SYS.SYSTEM
select count(*) from dba_objects where status = 'INVALID';
COUNT(*)
----------------
      149

The critical point here is the name of the created table. As soon as you are creating a table named SYSTEM under the SYS schema, you will get immediately a huge number of invalid objects under SYS, most of them are DBMS-Packages, ALL-Views and DBA-Views. The number of invalid objects you will get is depending on your Oracle Release, even a recompile with utlrp.sql will not validate all objects, there will still be invalid objects.

To get ride of this problem, just drop the table SYS.SYSTEM and recompile all with the utlrp.sql script.

This shows clearly why you should not allow the creation of application related objects under the SYS schema.

0 Comments :: Why you should never create own objects under SYS

Post a Comment