Skip to Main Content
  • Questions
  • Database objects: package spec and bodies

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, santhoshreddy.

Asked: January 16, 2018 - 2:05 pm UTC

Last updated: January 16, 2018 - 5:30 pm UTC

Version: 11g

Viewed 1000+ times

You Asked

Hi,

Are package body and package specifications different objects,bcz in DBA_OBJECTS view i see different object_id's for same package body and specification?

and Chris said...

Yes, they're separate objects. A package spec can exist without a body (though not the reverse):

create or replace package pkg as 
end;
/

create or replace package body pkg as 
begin
  null;
end;
/

select object_id, object_type 
from   user_objects
where  object_name = 'PKG';

OBJECT_ID   OBJECT_TYPE    
      76889 PACKAGE        
      76890 PACKAGE BODY  

drop package body pkg;

select object_id, object_type 
from   user_objects
where  object_name = 'PKG';

OBJECT_ID   OBJECT_TYPE   
      76889 PACKAGE   


Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library