set termout off store set sqlplus_settings replace set serveroutput on size 1000000 set linesize 130 set pagesize 120 set verify off set head off ttitle off btitle off clear columns clear breaks PROMPT PROMPT ###################################################################### PROMPT PROMPT -- Name : listSystemTablespaceUsersInfo.sql PROMPT PROMPT -- Copyright (c) DTA Inc., All Rights Reserved (2003) PROMPT PROMPT -- Description : This utility will display all who have SYSTEM as their default tablespaces PROMPT PROMPT -- Input(s) : None PROMPT PROMPT -- Output : The output is in a file named sessionsInfo__.lst PROMPT PROMPT -- Note : Run this script while connected as the SYS user PROMPT ###################################################################### PROMPT column username format a30 heading "USER" wrap column guilty heading "USES SYSTEM FOR" word_wrap -- Get database name and store in variable column name new_value s_dbname SELECT rtrim(name) name FROM v$database; -- Get today's date column today new_value s_curDate SELECT to_char(sysdate, 'Month DD, YYYY') today FROM dual; -- Get host name and store in variable column host_name new_value s_machine SELECT host_name from v$instance; set termout on set feedback off set head on spool systemTablespaceUsersInfo_&s_dbname._&s_machine ttitle left &s_curDate - center "Users having SYSTEM as default tablespace in " &s_dbname " on " &s_machine skip 2 select username, decode(default_tablespace,'SYSTEM', decode(temporary_tablespace,'SYSTEM', 'DEFAULT AND TEMPORARY TABLESPACES','DEFAULT TABLESPACE'), 'TEMPORARY TABLESPACE') guilty from sys.dba_users where default_tablespace = 'SYSTEM' or temporary_tablespace = 'SYSTEM'; spool off ttitle off btitle off clear columns clear breaks set feedback on set termout on set verify on PROMPT PROMPT -- If file is empty, no system tablespace information was found for the database &s_dbname PROMPT PROMPT PROMPT Output file systemTablespaceUsersInfo_&s_dbname._&s_machine..LST produced PROMPT @sqlplus_settings