set verify off

/*  Create user  */
create user &&perfstat_user
  identified by &&perfstat_password
  default tablespace &&default_tablespace
  temporary tablespace &&temporary_tablespace;

alter user &&perfstat_user quota unlimited on &&default_tablespace;

/*  System privileges  */
grant create session              to &&perfstat_user;
grant alter  session              to &&perfstat_user;
grant create table                to &&perfstat_user;
grant create procedure            to &&perfstat_user;
grant create sequence             to &&perfstat_user;
grant create public synonym       to &&perfstat_user;
grant drop   public synonym       to &&perfstat_user;


/*  Select privileges on STATSPACK created views  */
grant select on STATS$X_$KCBFWAIT       to &&perfstat_user;
grant select on STATS$X_$KSPPSV         to &&perfstat_user;
grant select on STATS$X_$KSPPI          to &&perfstat_user;
grant select on STATS$V_$FILESTATXS     to &&perfstat_user;
grant select on STATS$V_$TEMPSTATXS     to &&perfstat_user;
grant select on STATS$V_$SQLXS          to &&perfstat_user;
grant select on STATS$V_$SQLSTATS_SUMMARY to &&perfstat_user;

/*  Roles  */
grant SELECT_CATALOG_ROLE         to &&perfstat_user;

/*  Select privs for catalog objects - ROLES disabled in PL/SQL packages  */
grant select on V_$PARAMETER      to &&perfstat_user;
grant select on V_$SYSTEM_PARAMETER to &&perfstat_user;
grant select on V_$DATABASE       to &&perfstat_user;
grant select on V_$INSTANCE       to &&perfstat_user;
grant select on GV_$INSTANCE      to &&perfstat_user;
grant select on V_$LIBRARYCACHE   to &&perfstat_user;
grant select on V_$LATCH          to &&perfstat_user;
grant select on V_$LATCH_MISSES   to &&perfstat_user;
grant select on V_$LATCH_CHILDREN to &&perfstat_user;
grant select on V_$LATCH_PARENT   to &&perfstat_user;
grant select on V_$ROLLSTAT       to &&perfstat_user;
grant select on V_$ROWCACHE       to &&perfstat_user;
grant select on V_$SGA            to &&perfstat_user;
grant select on V_$BUFFER_POOL    to &&perfstat_user;
grant select on V_$SGASTAT        to &&perfstat_user;
grant select on V_$SYSTEM_EVENT   to &&perfstat_user;
grant select on V_$SESSION        to &&perfstat_user;
grant select on V_$SESSION_EVENT  to &&perfstat_user;
grant select on V_$SYSSTAT        to &&perfstat_user;
grant select on V_$WAITSTAT       to &&perfstat_user;
grant select on V_$ENQUEUE_STATISTICS to &&perfstat_user;
grant select on V_$SQLAREA        to &&perfstat_user;
grant select on V_$SQL            to &&perfstat_user;
grant select on V_$SQLTEXT        to &&perfstat_user;
grant select on V_$SESSTAT        to &&perfstat_user;
grant select on V_$BUFFER_POOL_STATISTICS to &&perfstat_user;
grant select on V_$RESOURCE_LIMIT to &&perfstat_user;
grant select on V_$DLM_MISC       to &&perfstat_user;
grant select on V_$UNDOSTAT       to &&perfstat_user;
grant select on V_$SQL_PLAN       to &&perfstat_user;
grant select on V_$DB_CACHE_ADVICE to &&perfstat_user;
grant select on V_$PGASTAT        to &&perfstat_user;
grant select on V_$INSTANCE_RECOVERY to &&perfstat_user;
grant select on V_$SHARED_POOL_ADVICE     to &&perfstat_user;
grant select on V_$SQL_WORKAREA_HISTOGRAM to &&perfstat_user;
grant select on V_$PGA_TARGET_ADVICE      to &&perfstat_user;
grant select on V_$SEGSTAT                  to &&perfstat_user;
grant select on V_$SEGMENT_STATISTICS       to &&perfstat_user;
grant select on V_$SEGSTAT_NAME             to &&perfstat_user;
grant select on V_$JAVA_POOL_ADVICE         to &&perfstat_user;
grant select on V_$THREAD                   to &&perfstat_user;
grant select on V_$CR_BLOCK_SERVER          to &&perfstat_user;
grant select on V_$CURRENT_BLOCK_SERVER     to &&perfstat_user;
grant select on V_$INSTANCE_CACHE_TRANSFER  to &&perfstat_user;
grant select on V_$FILE_HISTOGRAM           to &&perfstat_user;
grant select on V_$TEMP_HISTOGRAM           to &&perfstat_user;
grant select on V_$EVENT_HISTOGRAM          to &&perfstat_user;
grant select on V_$EVENT_NAME               to &&perfstat_user;
grant select on V_$SYS_TIME_MODEL           to &&perfstat_user;
grant select on V_$SESS_TIME_MODEL          to &&perfstat_user;
grant select on V_$STREAMS_CAPTURE           to &&perfstat_user;
grant select on V_$STREAMS_APPLY_COORDINATOR to &&perfstat_user;
grant select on V_$STREAMS_APPLY_READER      to &&perfstat_user;
grant select on V_$STREAMS_APPLY_SERVER      to &&perfstat_user;
grant select on V_$PROPAGATION_SENDER        to &&perfstat_user;
grant select on V_$PROPAGATION_RECEIVER      to &&perfstat_user;
grant select on V_$BUFFERED_QUEUES           to &&perfstat_user;
grant select on V_$BUFFERED_SUBSCRIBERS      to &&perfstat_user;
grant select on V_$RULE_SET                  to &&perfstat_user;
grant select on V_$OSSTAT                    to &&perfstat_user;
grant select on V_$PROCESS                   to &&perfstat_user;
grant select on V_$PROCESS_MEMORY            to &&perfstat_user;
grant select on V_$STREAMS_POOL_ADVICE       to &&perfstat_user;
grant select on V_$SGA_TARGET_ADVICE         to &&perfstat_user;
grant select on V_$SQLSTATS                  to &&perfstat_user;
grant select on V_$MUTEX_SLEEP               to &&perfstat_user;

/*  Packages  */
grant execute on DBMS_SHARED_POOL to &&perfstat_user;
grant execute on DBMS_JOB         to &&perfstat_user;

