I have more than 10+ views in my database(i.e. myDb) in snowflake with the role analyst.
Now, I have created a new role i.e. developer and I want to give
grant select on view <> to role developer
permission to one particle view(i.e test_view).
How can I grant access to one particular view in snowflake?
Note: consider the schema name public
Along with granting select on view, you also need to grant usage on the database and schema
grant usage on database db_name to role developer;
grant usage on schema db_name.public to role developer;
grant select on view db_name.public.my_view to role developer;
Operating on a view also requires the USAGE privilege on the parent
database and schema
snowflake-view-privileges
You do it almost exactly how you have guessed. VIEWs are schemaObjectPrivileges
CREATE ROLE developer;
CREATE VIEW test.test.test_view AS SELECT 1 AS id;
GRANT SELECT ON VIEW test.test.test_view TO ROLE developer;
SHOW GRANTS TO ROLE developer;
Related
Three days ago, I created another user, it's ok. Now I create another user, not working. I don't know what I missed.
This time I did:
CREATE USER TESTDB identified by N2dTlOBFRZ9x;
GRANT CONNECT, RESOURCE TO TESTDB;
GRANT CREATE SESSION TO TESTDB;
GRANT UNLIMITED TABLESPACE TO TESTDB;
GRANT CREATE TABLE to TESTDB;
GRANT CREATE VIEW to TESTDB;
I can create a view, named viewTest, save it.
TESTDB viewTest
select * from PRODDB.employee
Then open viewTest, it says insufficient privileges.
I have another user. let's call it PRODDB. This is online database
The user I created 3 days ago, is OKDB.
Today I created one another, TESTDB.
In OKDB, I created a view (viewTest) and I can open it.
select * from PRODDB.employee;
But in TESTDB, cannot open.
Thank you for the update! I believe this is a permissions issue.
In OKDB, I created a view and I can open it. select * from
PRODDB.employee;
But in TESTDB, cannot open.
So in this example, there are three users: 1. PRODDB, 2. OKDB, and 3. TESTDB.
The view is named Employee and was created under the PRODDB schema; PRODDB.EMPLOYEE.
If OKDB can query PRODDB.EMPLOYEE, one of two things have to be true. Either: 1. OKDB was granted privileges on PRODDB.EMPLOYEE directly (e.g. grant select on PRODDB.EMPLOYEE to OKDB;), or 2. OKDB has elevated privileges through a role that enables the user to query that view (e.g. grant DBA to OKDB, which will allow OKDB to query any table in the database.)
If TESTDB can't query the view, I would bet that the necessary privileges have not been granted to the user. To fix this, I would recommend checking the privileges and roles that have been granted to the OKDB user and then granting the same privilege(s) to TESTDB. If this is something work related, you may have to work with another DBA if you do not have permission to issue grants.
I have a schema that contains the vast majority of tables on my project, DEV2.
Additionally, I have a schema that contains oracle custom types used by DEV2: PUBLIC_TYPES.
I want to be able to create triggers on DEV2 that access the roles in PUBLIC_TYPES, but would prefer to do this with a role, so that when I create DEV3 (a clone of DEV2), I can just grant the role to DEV3 prior to compiling the triggers.
At the moment, if I perform the following:
grant all on public_types.type_name to DEV2;
and then (on the DEV2 user) I type:
desc public_types.type_name;
I get the proper description of the type.
However, if I instead do the following:
create role TABLE_PRIVS;
grant all on public_types.type_name_2 to TABLE_PRIVS;
grant table_privs to DEV2;
(and then switch to my DEV2 user, and desc)
desc public_types.type_name_2
I get
ORA-04043: object public_types.type_name_2 does not exist
What am I missing? I've granted the privilege to a role, and the role to a user. Does this work differently with types?
Thanks in advance!
Try to add role to user as default
grant table_privs to DEV2;
ALTER USER DEV2 DEFAULT ROLE table_privs;
otherwise you need to use SET ROLE
I want to create a view in SCHEMA_A using columns from a table LICENSE in SCHEMA_B.
create view SCHEMA_B.V_TEST as
SELECT LICENSE_NUMBER FROM SCHEMA_A.LICENSE L
then
select * from SCHEMA_B.V_TEST
This is giving me "ORA-01031: insufficient privileges" when I try to select from the view as the admin account. (Edit: admin account has SELECT ANY TABLE privileges.) What am I missing?
There is a similar question but the solution has to do with one user granting select to another. Since I'm admin I should have select privilege on both schemas already? However I have tried adding the line "GRANT SELECT ON SCHEMA_A.LICENSE TO admin_account WITH GRANT OPTION" and get the same error.
I think that the creation of the view fails, because schema_b doesn't have select privilege to schema_a.licence. Since you're creating an object in the schema_b, schema_b must have the necessary privilege.
Grant it:
as schema_a (or an DBA - "admin account")
grant select on schema_a.licence to schema_b
then you should be able to create the view and then select from it.
I have created a new user using the below in sql developer (Oracle 11g). I have only two tables titled FEED_DATA_A and FEED_DATA_B that I want this user to be able to select, update and insert into. Can someone help me understand the SQL to create the proper privileges to accomplish that? I'm currently logged in as the system user.
CREATE USER "USER_A" IDENTIFIED BY "test123";
If you want to grant the privileges directly to the user
GRANT select, update, insert
ON table_owner.feed_data_a
TO user_a;
GRANT select, update, insert
ON table_owner.feed_data_b
TO user_a;
More commonly, though, you would create a role, grant the role to the user, and grant the privileges to the role. That makes it easier in the future when there is a new user created that you want to have the same privileges as USER_A to just grant a couple of roles rather than figuring out all the privileges that potentially need to be granted. It also makes it easier as new tables are created and new privileges are granted to ensure that users that should have the same privileges continue to have the same privileges.
CREATE ROLE feed_data_role;
GRANT select, update, insert
ON table_owner.feed_data_a
TO feed_data_role;
GRANT select, update, insert
ON table_owner.feed_data_b
TO feed_data_role;
GRANT feed_data_role
TO user_a
I am logging into oracle as a simple user.I want other user who are logged in to the same database as i am ,be able to see and manipulate tabels and stored procedure.
I used grant privilege to achieve this.
grant all on tablename to user;
but it is not working ie on querying the table it is showing no such table or view exists.
How should i achieve this.
The other user may have to use a schema name when accessing the table. eg. select * from user1.table1