dbms_lock.sleep Grant Execute Privilege in Oracle

I will explain dbms_lock.sleep Grant Execute Privilege in Oracle in this post.

dbms_lock.sleep Grant Execute Privilege in Oracle

Developers or some database users want to use and run dbms_lock.sleep but they are not allowed to grant EXECUTE privilege on the whole package but can grant for specific procedure in the package.




grant execute on sys.dbms_lock

You can give this permission to the users as follows.

SQL> grant execute on sys.dbms_lock to MSDBA;

Grant succeeded.

SQL> grant execute on sys.dbms_lock to BIGDATA;

Grant succeeded.



Sometimes you can get the following error while granting this privilige.

We could not grant privilege directly to non-DBA users due to the following error:

SQL> conn <user_name>/<password> as sysdba
SQL> GRANT EXECUTE ON sys.dbms_lock.sleep TO appuser;
GRANT EXECUTE ON sys.dbms_lock.sleep TO appuser
ERROR at line 1:
ORA-00905: missing keyword

But we can create another procedure under SYS and then grant the privilege to a non-DBA users with below steps:

-- create appuser user:
create user appuser identified by <PASSWORD>;
grant resource, connect to appuser;
alter user appuser account unlock;

-- create usersleep() procedure
CREATE OR REPLACE PROCEDURE sys.usersleep(n in number) IS

-- grant privilege
GRANT EXECUTE ON sys.usersleep TO appuser;
-- Test Result:
SQL> show user
SQL> exec sys.usersleep(5);
-- Wait 5s --
PL/SQL procedure successfully completed.





If you want to learn more details about how to Grant and Revoke priviliges in Oracle, Read the following post. 


How to Grant and Revoke Privileges | Create and Drop any User in Oracle Database


Do you want to learn Oracle Database for Beginners, then Click and read the following articles.

Oracle Database Tutorials for Beginners ( Junior Oracle DBA )

About Mehmet Salih Deveci

I am Founder of SysDBASoft IT and IT Tutorial and Certified Expert about Oracle & SQL Server database, Goldengate, Exadata Machine, Oracle Database Appliance administrator with 10+years experience.I have OCA, OCP, OCE RAC Expert Certificates I have worked 100+ Banking, Insurance, Finance, Telco and etc. clients as a Consultant, Insource or Outsource.I have done 200+ Operations in this clients such as Exadata Installation & PoC & Migration & Upgrade, Oracle & SQL Server Database Upgrade, Oracle RAC Installation, SQL Server AlwaysOn Installation, Database Migration, Disaster Recovery, Backup Restore, Performance Tuning, Periodic Healthchecks.I have done 2000+ Table replication with Goldengate or SQL Server Replication tool for DWH Databases in many clients.If you need Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS Consultancy and Training you can send my email adress [email protected].-                                                                                                                                                                                                                                                 -Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS ve linux Danışmanlık ve Eğitim için  [email protected] a mail atabilirsiniz.

Leave a Reply

Your email address will not be published. Required fields are marked *