Query to generate grant privileges in Oracle DB

Goal

To generate grant instructions for tables in an Oracle DB specific schema

Description

This recipe provides a simple yet effective mechanism to generate the necessary instructions to make it possible to grant privileges on specific tables in an Oracle DB schema.

How to

Go to your Oracle SQL developer (or any other client connection you use) and execute the following instruction (adapt to your own needs):

SELECT 'GRANT ALL ON <schema>.' || table_name || ' to <schema>;' FROM dba_tables WHERE OWNER = '<schema>';

Now, simply copy the instructions and execute them.

Explanations

Executing the previous statement’s generated instructions will grant access to all tables on schema <schema>.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s