Unable to grant role to user - sql

I've created a role called CATDX_OWNER_RPT_RL and granted SELECT privileges on all tables within the schema. I've created a new user and granted both CONNECT, CREATE SESSION. Now I would like to assign the role I created to the new user with the following syntax - GRANT ROLE CATDX_OWNER_RPT_RL TO USER. It returns this error SQL Error: ORA-00990: missing or invalid privilege
00990. 00000 - "missing or invalid privilege"

Reinventing the wheel? Omit ROLE.
GRANT CATDX_OWNER_RPT_RL TO NEW_USER;

Related

Grant create user permission Snowflake

Its a newbie question but still I am trying to grant create user permission to sysadmin role from the accountAdmin role so that I can create users in the sysadmin role.
The statement I am trying to execute is:
grant create user to role sysadmin;
Error
SQL compilation error: syntax error line 1 at position 18 unexpected 'to'.
What's the exact statement to achieve this?
I tried googling but haven't found any exact query statement in a long time, so posting it here.
Grant create user on account to role role_name ;
Please note that this statement has to be submitted as an ACCOUNTADMIN
https://docs.snowflake.com/en/sql-reference/sql/grant-privilege.html
You could also choose to use the WITH GRANT OPTION which allows the grantee to regrant the role to other users.
Grant create user on account to role role_name WITH GRANT OPTION;

Problem of privileges when creating a link between schemas

I am trying to create a link between two schemas in SQL Developer and I have an error. The querie I am executing is:
CREATE DATABASE LINK dblink
CONNECT TO Matecode IDENTIFIED BY Matecode
USING 'Matecode';
Where Matecode it's the remote user, password and database Schema I want to be conected. Like this:
CREATE DATABASE LINK dblink
CONNECT TO remote_user IDENTIFIED BY password
USING 'remote_database';
But I am receiving this error
00000 - "insufficient privileges"
*Cause: An attempt was made to perform a database operation without
the necessary privileges.
*Action: Ask your database administrator or designated security
administrator to grant you the necessary privileges
The password and the user are ok.
Check you have "create database link" privilege to the schema where you are creating the Database link. if the privilege is not granted use below statement as 'sysdba' user to grant the "create database link" and then try to create the database link.
SQL:
grant CREATE DATABASE LINK to username;

AWS RDS - Oracle - Grant permissions on sys

I'm trying to create a role and grant select permissions on sys.dba_objects.
This is my sql:
grant select on sys.dba_objects to my_role
grant select on sys.dba_objects to my_role;
On RDS I get the following error:
Error: ORA-01031: insufficient privileges
I saw that RDS has a dedicated stored procedure for granting permissions on sys. I tried:
call rdsadmin.rdsadmin_util.grant_sys_object('SYS.REGISTRY$HISTORY', 'my_role', 'select')
Error I get:
ORA-44003: invalid SQL name
ORA-06512: at "RDSADMIN.RDSADMIN_UTIL", line 248
ORA-44003: invalid SQL name
ORA-06512: at line 1
This is how I made it work:
1. Removed the sys. prefix like suggested above
2. Used uppercase
Example:
call rdsadmin.rdsadmin_util.grant_sys_object('DBA_OBJECTS', 'ASSESSMENT_ROLE', 'SELECT');
I don't know AWS RDS, but ORA-01031 sounds like a known restriction: privileges granted via roles won't work in PL/SQL procedures - you'll have to grant them directly to user.
Try following...First you need to grant select to rdsadmin with grant option using SYS.
As SYS
grant select on DBA_objects to rdsadmin with grant option;
As rdsadmin
grant select on sys.dba_objects to my_role;

Creating a user in Oracle 11g - No permissions issue

I am trying to set up a user in my Oracle 11g database as such
create user BARRY6 IDENTIFIED by password123;
grant connect to BARRY6;
grant create session to BARRY6;
grant UNLIMITED TABLESPACE to BARRY6;
commit;
This should create the user and provides them with the basic permissions.
All commands executes successfully, However i can not connect with this user.
I get an error
An error was encountered performing the requested operation:
ORA-01031: insufficient privileges
01031. 00000 - "insufficient privileges"
*Cause: An attempt was made to perform a database operation without
the necessary privileges.
*Action: Ask your database administrator or designated security
administrator to grant you the necessary privileges
Vendor code 1031
When i view the USER_ROLE_PRIVS table , there is no permissions in that table for my user
This was happening because the role i was trying to login in as was sysdba. While it should be default.
I know, stupid, but it posting the solution in case other people are creating a user and they make this simple mistake. It was caused by loading the sys connection and just changing the password and not changing the role

H2 database 'grant role' error

I'm writing some database creation scripts using H2 database but can't grant the roles I create. My script is:
create user MY_READWRITEUSER password 'MY_READWRITEUSER';
create user MY_OWNER password 'MY_OWNER' admin ;
create schema MY_OWNER AUTHORIZATION MY_OWNER;
set schema MY_OWNER;
create role MY_READ_ROLE;
create role MY_RW_ROLE;
grant role MY_RW_ROLE to MY_OWNER;
grant role MY_RW_ROLE to MY_READWRITEUSER;
grant role MY_READ_ROLE to MY_READUSER;
but when I hit the grant role lines H2 complains:
[Error Code: 42001, SQL State: 42001] Syntax error in SQL statement "GRANT ROLE MY_RW_ROLE[*] TO MY_OWNER "; expected ",, TO"; SQL statement:
I don't see any syntax error - what am I doing wrong?
H2 version 1.4.191
Often the case - if I ask on SO I figure out the answer myself minutes later.
There is a syntax error. This:
grant role MY_RW_ROLE to MY_OWNER;
should say this:
grant MY_RW_ROLE to MY_OWNER;