Skip to Main Content
  • Questions
  • When replace PACKAGE do I need to recreate GRANT and SYNONYM

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Hong.

Asked: January 24, 2018 - 3:26 pm UTC

Last updated: January 25, 2018 - 2:59 am UTC

Version: 11.2.0.3.0

Viewed 10K+ times! This question is

You Asked

I have PACKAGEs that already set the GRANTs and SYNONYMs. I want to make some changes to a PACKAGE:

create or replace PACKAGE "AAA_PKG"

After that do I need to reset the GRANTs and SYNONYMs?

CREATE OR REPLACE SYNONYM ABC.AAA_PKG FOR SCHEMA.AAA_PKG;
GRANT SELECT ON SCHEMA.AAA_PKG TO SCHEMA_READONLY_ROLE;

Thank you.

and Connor said...

No you do not. Only if you *drop* the package would you need to re-issue the grants. The synonyms stay no matter what.

SQL> conn mcdonac/password

SQL> create or replace
  2  package BLAH is
  3    some_var int;
  4  end;
  5  /

Package created.

SQL>
SQL> conn scott/tiger
Connected.

SQL> exec mcdonac.blah.some_var := 0;
BEGIN mcdonac.blah.some_var := 0; END;

              *
ERROR at line 1:
ORA-06550: line 1, column 15:
PLS-00904: insufficient privilege to access object MCDONAC.BLAH
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored


SQL> conn mcdonac/password
Connected.

SQL> grant execute on blah to scott;

Grant succeeded.

SQL>
SQL> conn scott/tiger
Connected.

SQL> exec mcdonac.blah.some_var := 0;

PL/SQL procedure successfully completed.

SQL>
SQL> conn mcdonac/password
Connected.

SQL>
SQL> create or replace
  2  package BLAH is
  3    some_var int;
  4    some_more_var int;
  5  end;
  6  /

Package created.

SQL>
SQL>
SQL> conn scott/tiger
Connected.

SQL> exec mcdonac.blah.some_var := 0;

PL/SQL procedure successfully completed.

SQL>



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

More to Explore

Administration

Need more information on Administration? Check out the Administrators guide for the Oracle Database