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;
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;
Fast :
GRANT SELECT ON SYSTEM.* TO appadmin;
I want to grant AppAdmin the rights of SELECT on all tables of the database
I'm using Oracle SQL, why does my statement not work ?
Using the ANY keyword in reference to a system privilege means that the user can perform the privilege on any objects owned by any user except for SYS. By default, if you are granted a privilege, you cannot assign your privilege to others. You cannot grant or revoke that privilege to or from anyone else.
Sometimes you want to grant privileges to users and have them be able to grant those privileges to other users. When this is the case, we include the with admin keyword in the grant command. When this keyword is used, it will allow the user granted the privilege to grant that privilege to other users.
Here is an example of the usage of the with admin option keyword.
GRANT SELECT ANY TABLE TO User;
GRANT SELECT ANY TABLE TO YOUR_USER;
I'm trying to export data from a query into a csv file from Oracle Enterprise Express installed on a Windows Server 2008 machine.
I've found this solution:
http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:235814350980
which basically writes a function and uses the UTIL_FILE object to create and write to a file and add delimiters.
I receive the follow error when I try and create the function in Oracle SQL Developer:
PLS-00201: identifier UTIL_FILE must be declared.
When I run the following command:
select owner, object_type from all_objects where object_name = 'UTL_FILE'
The result is:
OWNER Object Type
--------- -----------
PUBLIC SYNONYM
EDIT:
Running:
GRANT EXECUTE ON UTL_FILE TO PUBLIC
Gives:
Error starting at line 2 in command:
GRANT EXECUTE ON UTL_FILE TO PUBLIC
Error report:
SQL Error: ORA-00942: table or view does not exist
00942. 00000 - "table or view does not exist"
*Cause:
*Action:
What is the problem?
Seems like lack of privileges to me. Often PUBLIC user has EXECUTE privilege granted on that package, but the privilege may be revoked.
You can check if PUBLIC has that privilege by issuing the following query:
SELECT * FROM all_tab_privs WHERE grantee = 'PUBLIC' AND table_name = 'UTL_FILE';
If there are no rows returned, try granting the execute privilege to either the user you are logged as, or to PUBLIC, as some privileged user, for example SYS:
GRANT EXECUTE ON SYS.utl_file TO user_name;
Edit
You must grant the privilege while being logged as, for example, SYS user.
Users do not have execute permission on UTL_FILE by default. To use UTL_FILE, an ADMIN user or instance administrator must explicitly GRANT EXECUTE permission on it, such as in the following example:
GRANT EXECUTE ON SYS.UTL_FILE TO scott;
Aside from the possible lack of permissions that other answers have covered, your question says the error you get is:
PLS-00201: identifier UTIL_FILE must be declared
That suggests you've referenced UTIL_FILE, rather than the built-in package UTL_FILE, in your function. It might be an error you've introduced writing the question, of course, but you used it in the text too so maybe you have got the package name wrong in your code, if you didn't just copy-and-paste Tom's code.
You'll still need execute privileges on UTL_FILE anyway, if you don't have them already.
As user: h_djebli pointed out in his comment you need to be connected as SYS user in the first place.
To do that, you have to be in your oracle home directory :
cd $ORACLE_HOME
Then execute :
sqlplus / as sysdba
sqlplus will start in your terminal and you'll be connected as the SYS user.
You can finally write the GRANT command in your sqlplus console :
GRANT EXECUTE ON SYS.utl_file TO your_db_username;
We can do this via cmd, with these steps:
Login as sysdba (connect sys as sysdba + enter password as sys_password)
grant execute on utl_file to <user_name>.
now we can check by query :'SELECT * FROM all_tab_privs WHERE grantee = 'PUBLIC' AND table_name = 'UTL_FILE';'
Hi
I was trying to execute
grant all on Owner.table_name to APPS,ABC;
but it is giving an error that grant privileges not provided.
Please let me know how can i get and what is the reason.
You need Owner to: GRANT ANY PRIVILEGE TO You;
You will see that you do not have it by running:
select * from system_privilege_map
where name like '%PRIV%';