Grants for all tables

Moderator: NorbertKrupa

Post Reply
User avatar
Josh
Intermediate
Intermediate
Posts: 106
Joined: Thu Jan 26, 2012 9:38 pm

Grants for all tables

Post by Josh » Fri Feb 17, 2012 8:39 pm

Is there a quick way to grant select on all the tables of a schema to a user?
Thank you!
Joshua

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1825
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: Grants for all tables

Post by JimKnicely » Fri Feb 17, 2012 10:16 pm

Josh,

You can do this from within vsql rather easily by using SQL to generate SQL grant statements.

Say I want to grant the select privilege on the tables in the schema v_schema1 to the v_main_user user. I could do this in vsql:

Code: Select all

dbadmin=> \o grants.sql
dbadmin=> select 'grant select on v_schema1.' || table_name || ' to v_main_use;' from tables where table_schema = 'v_schema1';
dbadmin=> \o
dbadmin=> \i grants.sql
Note: The \o switch saves the results from the SELECT statement into an output file and the \i switch allows you to execute the commands from a file.
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

Post Reply

Return to “Vertica Database Administration”