Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grant select on view

somewhere along the way something is going wrong, and I can't seem to find out why. If this is already asked apologies.

I have 3 schema's in my database: COLLDESK LOCAL_IT GERBEN

COLLDESK is our main schema, LOCAL_IT is where we do our local development, and GERBEN is the end user (should only have select options).

Now I have a table in my COLLDESK schema called GESTIONES. In LOCAL_IT I have a view called ACTIONS. This is holding 4 columns from the table GESTIONES in the COLLDESK schema. So far so good!

Now I want to give the GERBEN schema select privileges in the view ACTIONS. But when I say

grant select on LOCAL_IT.ACTIONS to GERBEN

I get the error ORA-01720: grant option does not exist for COLLDESK.GESTIONES

Now I tried giving GERBEN select privileges to GESTIONES, but I am still getting the error message

Any help would be greatly appreciated!

Kind regards

Gerben

like image 446
Gerben Avatar asked Jun 19 '14 13:06

Gerben


People also ask

How do you grant select access to view?

For the existing view, you can go to the Properties of the view in SSMS, add users in the Permissions, and then grant select permission in the permissions list. Or use the following statement to grant user permissions: GRANT SELECT ON OBJECT::[schema]. [yourview] TO User1,User2.

Can we grant select on view in Oracle?

grant select on schema1. table1 to schema2 with grant option; Now schema2, is allowed to grant select on its view to 3rd parties: grant select on schema2.

Can we use grant command on view?

Note: To grant privileges to all tables (or views) contained within a database, simply grant the privilege to the database. If the ALL [PRIVILEGES] keywords are specified following GRANT, all table or view privileges (for which the issuer has GRANT authority) are granted for the objects identified in the ON clause.

How do I grant a view in SQL?

Connect to SQL Server using the login credentials having Public role permission. Execute the query to get the view definition of an object. The command sp_helptext gives an error message that an object does not exist in the database. If we try to get the script using INFORMATION_SCHEMA.


1 Answers

The error message should be written like this:

ORA-01720: "grant option" does not exist for COLLDESK.GESTIONES.

Here's how it works:

You have 3 schemas:

  • Schema1 - Holder of a table named "table1"
  • Schema2 - Holder of a view "view1" selecting from schema1.table1
  • Schema3 - User, selecting from schema2.view1 - has no select granted on schema1.table1.

You probably have done the following:

grant select on schema1.table1 (COLLDESK.GESTIONES) to schema2;

Note that since you're creating a view, the select must granted directly to schema2, your view won't work if the select is granted through a role.

Now you are trying to allow a 3rd schema (schema3) to use the view read data from schema1. For security purposes, a schema2 will never be allowed to access data from schema1 to a 3rd schema even if it can view the data. This would be a huge security hole otherwise.

So the solution is to make it explicit that schema2 will be able to grant that select privilege, indirectly, when a 3rd party is granted the select privilege on the view.

Solution:

grant select on schema1.table1 to schema2 with grant option;

Now schema2, is allowed to grant select on its view to 3rd parties:

grant select on schema2.view1 to schema3;

For you:

grant select on COLLDESK.GESTIONED to LOCAL_IT with grant option;
grant select on LOCAL_IT.ACTIONS to GERBEN;

Also: Avoid using public views and public db links unless absolutely necessary. Deplete every other options first.

like image 148
Nicolas de Fontenay Avatar answered Oct 11 '22 19:10

Nicolas de Fontenay