Create grant command for table / view based on other object

It is just small stupid hint but sometimes it can help. This query gives you grant commands for some table / view based on other object:

SELECT ‘ GRANT ‘ || PRIVILEGE || ‘ ON ‘ || ‘…your_target_object_with_schema_name….’
|| ‘ TO ‘ || GRANTEE ||
DECODE (GRANTABLE, ‘YES’ , ‘ WITH GRANT OPTION’, ”)
|| ‘;’
FROM ALL_TAB_PRIVS
WHERE TABLE_SCHEMA = ‘…source_object_schema…’ AND TABLE_NAME = ‘…source_object….’

[/sql

Leave a Reply

Your email address will not be published. Required fields are marked *