-- #############################################################################################
--
-- %Purpose: Creates a script that grants a user access to the SYS tables (V$%)
--
-- Creates a script called vgrant.sql that grants a user access
-- to the SYS tables used by most of the scripts in this directory.
--
-- Before you run this script, copy it and change the <username> below.
-- You must be logged in as SYS to run this script.
--
-- #############################################################################################
--
set pagesize 0 feedback off
spool vgrant.sql

select 'grant select on sys.ext_to_obj to <username>;' from dual
/
select
  'grant select on ' || table_name || ' to <username>;'
   from all_synonyms
   where synonym_name like 'V$%' or synonym_name like 'DBA%'
/

spool off
set pagesize 24 feedback on
