Updating some scripts from 18 to 19, but getting this
Have also tried just DBMS_LOCK instead of SYS.DBMS_LOCK
SQL> GRANT EXECUTE ON SYS.DBMS_LOCK to myuser;
GRANT EXECUTE ON SYS.DBMS_LOCK to myuser
*
ERROR at line 1:
ORA-04042: procedure, function, package, or package body does not exist
sqlplus "sys/ChangeMe123! AS SYSDBA"
Note - other grants worked
SQL> GRANT ALTER SESSION TO myuser;
Grant succeeded.
SQL> GRANT CREATE PROCEDURE TO myuser;
Grant succeeded.
SQL> GRANT CREATE SEQUENCE TO myuser;
Grant succeeded.
SQL> GRANT CREATE SESSION TO myuser;
Grant succeeded.
SQL> GRANT CREATE MATERIALIZED VIEW TO myuser;
Grant succeeded.
SQL> GRANT CREATE TABLE TO myuser;
Grant succeeded.
SQL> GRANT CREATE TRIGGER TO myuser;
Grant succeeded.
SQL> GRANT CREATE VIEW TO myuser;
Grant succeeded.
SQL> GRANT CREATE ANY SYNONYM TO myuser;
Grant succeeded.
SQL> GRANT DROP ANY SYNONYM TO myuser;
Grant succeeded.
SQL> GRANT SELECT ANY DICTIONARY TO myuser;
Grant succeeded.
SQL> GRANT EXECUTE ON DBMS_LOCK to myuser;
GRANT EXECUTE ON DBMS_LOCK to myuser
DBMS_LOCK.SLEEP was deprecated replaced with DBMS_SESSION.SLEEP but still available in 19c for backwards compatibility.Verify if object exists
SQL> select object_name,object_type,owner from dba_objects
2 where object_name='DBMS_LOCK';
OBJECT_NAME OBJECT_TYPE OWNER
------------------------------ ----------------------- ------------------------------
DBMS_LOCK PACKAGE SYS
DBMS_LOCK PACKAGE BODY SYS
DBMS_LOCK SYNONYM PUBLIC
If above query returns nothing then run the dbmslock script as a sysdba that creates above package
sql>#?/rdbms/admin/dbmslock
Related
I have a database TRADES with few users and one of them is having the necessary privilege.
Query USER_ROLE_PRIVS. For example, my Scott user doesn't have that privilege (its name is RECOVERY_CATALOG_OWNER:
SQL> connect scott/tiger
Connected.
SQL> select * from user_role_privs;
USERNAME GRANTED_ROLE ADM DEF OS_
------------------------------ ------------------------------ --- --- ---
SCOTT CONNECT NO YES NO
SCOTT RESOURCE NO YES NO
SQL>
But, if I grant it:
SQL> connect sys/pwd as sysdba;
Connected.
SQL> grant recovery_catalog_owner to scott;
Grant succeeded.
and check again:
SQL> connect scott/tiger
Connected.
SQL> select * From user_role_privs;
USERNAME GRANTED_ROLE ADM DEF OS_
------------------------------ ------------------------------ --- --- ---
SCOTT CONNECT NO YES NO
SCOTT RECOVERY_CATALOG_OWNER NO NO NO --> here it is
SCOTT RESOURCE NO YES NO
Aditionally, if you connect as a privileged user (such as sys) and wish to know which users were granted that role, then
SQL> select * from dba_role_privs where granted_role = 'RECOVERY_CATALOG_OWNER';
GRANTEE GRANTED_ROLE ADM DEF
------------------------------ ------------------------------ --- ---
SYS RECOVERY_CATALOG_OWNER YES YES
SCOTT RECOVERY_CATALOG_OWNER NO NO
SQL>
I am new to using Oracle database. I worked on it for some weeks. It worked well. But now, I'm having some problem. I am getting this error while trying to connect. I didn't change the password. I am using the default user name and password only.
SQL> connect as sysdba
Enter user-name: SCOTT
Enter password:
ERROR:
ORA-01031: insufficient privileges
Can someone tell the solution for this?
That's because SCOTT isn't granted a SYSDBA role. Have a look at his demonstration.
This is what you have now:
SQL> connect as sysdba
Enter user-name: scott
Enter password:
ERROR:
ORA-01031: insufficient privileges
Warning: You are no longer connected to ORACLE.
SQL>
Connect as a privileged user (SYS) and grant SYSDBA to SCOTT:
SQL> connect as sysdba
Enter user-name: sys
Enter password:
Connected.
SQL>
SQL> grant sysdba to scott;
Grant succeeded.
SQL>
OK; now, back to the initial attempt:
SQL> connect as sysdba
Enter user-name: scott
Enter password:
Connected.
SQL>
Not everyone has SYSDBA privileges, and not everyone should have them. Handle with care, it is a powerful privilege so I'll revoke it from SCOTT:
SQL> connect as sysdba
Enter user-name: sys
Enter password:
Connected.
SQL> revoke sysdba from scott;
Revoke succeeded.
SQL>
Please share more information like OS etc
But have you checked user you are using to connect is part of ORA_DBA group assuming you are on windows
I'm running an installer script. which is granting on sys.aux_stats$, sys.wri$optstat_aux_history, sys.dbms_spm and sys.dbms_xplan. At this point there is an exception throwed: ORA-01031: insufficient privileges For the installer I created a DBA-User (FOODBA) and a DB-User (FOOADM). The DBA is created like this on the oracle machine:
bash-4.1$ sqlplus
...
Enter user-name: sys as sysdba
Enter password:
SQL> CREATE USER FOODBA IDENTIFIED BY Password;
User created.
SQL> GRANT DBA TO FOODBA ;
Grant succeeded.
SQL> GRANT ADMINISTER SQL MANAGEMENT OBJECT TO FOODBA ;
Grant succeeded.
doesn't work at all, do I tried like this:
SQL> GRANT ALL PRIVILEGES TO FOODBA;
Grant succeeded.
Still not working, so I tried to give permission on custom object:
SQL> grant all privileges on sys.aux_stats$ to FOODBA;
Grant succeeded.
And when I run the script with user FOODBA:
grant select, insert, update, delete on sys.aux_stats$ to FOOADM
It's throwing again the insufficient privileges excpetion.
What I'm supposed to do, so that the FOODBA user can create and grant the FOOADM correctly? The install script is 3rd party.
Having an object grant is not sufficient to pass this grant on to another user/role. You will need "with grant option".
grant select, insert, update, delete on sys.aux_stats$ to FOODBA with grant option;
I am exporting database as:
exp system/passwd owner=weblogics file=/var/Downloads/dmp/weblogics61015.dmp log=/var/Downloads/dmp/weblogics61015.log statistics=none
Importing database as:
imp system/passwd fromuser=weblogics touser=weblogics file=/var/Downloads/dmp/weblogics61015.dmp log=/dmp/weblogics61015.log
SQL> select banner from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
SQL> select distinct tablespace_name from dba_segments where owner='weblogics';
no rows selected
Why I am not able to see my tablespace. What should I do?
1) The owner name must be in capital letters like WEBLOGICS not weblogics
2) you are using 11g so I strongly recommend to use datapump instead of imp/exp.
Your objects currently exist in the SYSTEM tablespace in the source db they'll get created in the system tablespace in the new db as the DDL for the tables will look like:
create table weblogics.tableName (col1) tablespace system;
So follow these steps:
SQL> SELECT directory_path FROM dba_directories WHERE directory_name = 'DATA_PUMP_DIR';
DIRECTORY_PATH
--------------------------------------------------------------------------------
D:\Oracle\app\PC-NAME/admin/xe/dpdump/
SQL> SELECT directory_path FROM dba_directories WHERE directory_name = 'DATA_PUMP_DIR';
DIRECTORY_PATH
--------------------------------------------------------------------------------
/u01/app/oracle/admin/XE/dpdump/
SQL> CREATE DIRECTORY dmpdir AS 'D:\Oracle\app\PC-NAME\admin\XE\dpdump\dmpdir';
Directory created.
SQL> GRANT read, write ON DIRECTORY dmpdir TO WEBLOGICS;
Grant succeeded.
Now you can export as:
expdp WEBLOGICS/pass DIRECTORY=dmpdir DUMPFILE=WEBLOGICS.dmp logfile=WEBLOGICS.log SCHEMAS=WEBLOGICS
Now for transferring SYSTEM to WEBLOGICS follow these steps:
create TABLESPACE WEBLOGICS
DATAFILE 'D:\Oracle\app\PC-NAME\oradata\XE\WEBLOGICS01.dbf' SIZE 10M
AUTOEXTEND ON
NEXT 512K
MAXSIZE 250M;
SQL> drop user WEBLOGICS cascade;
User dropped.
SQL> create user WEBLOGICS identified by pass;
User created.
SQL> grant connect, resource to WEBLOGICS;
Grant succeeded.
SQL> grant read, write on directory dmpdir to WEBLOGICS;
Grant succeeded.
SQL> grant create database link to WEBLOGICS;
Grant succeeded.
Now import data:
impdp WEBLOGICS/WEBLOGICS
remap_tablespace=SYSTEM:WEBLOGICS
dumpfile=WEBLOGICS.dmp directory=dmpdir
Now you can confirm it:
SQL> select diPC-NAMEnct tablespace_name from dba_segments where owner='WEBLOGICS';
Cheers!!
I want to grant execute permission to user B so that it can execute a packaged procedure belonging to user A.
procedure name = PKGNAME.PROCEDURENAME
user = USERA
I am trying below command:
GRANT EXECUTE ON USERA.PKGNAME.PROCEDURENAME TO USERB;
But it gives me error:
ERROR at line 1:
ORA-00905: missing keyword
is there a syntax problem ? I used this link :
Granting Rights on Stored Procedure to another user of Oracle
you can't grant permissions on a procedure which is within a package, either grant permissions to the entire package or move the procedure outside of the package so it's a stand alone one and then grant permission
so either
GRANT EXECUTE ON USERA.PKGNAME TO USERB;
or
GRANT EXECUTE ON USERA.PROCEDURENAME TO USERB;