set termout off store set sqlplus_settings replace set serveroutput on size 1000000 set linesize 132 set pagesize 120 set verify off set head off ttitle off btitle off clear columns clear breaks PROMPT ################################################################# PROMPT -- Name : listTablesNoIndexesInfo.sql PROMPT PROMPT -- Copyright (c) DTA Inc., All Rights Reserved (2003) PROMPT PROMPT -- Description : This script lists Tables without indexes and tables without P key PROMPT PROMPT -- Inputs(s) : None PROMPT PROMPT -- Output : The output is in a file named tablesNoIndexesInfo__.lst PROMPT PROMPT -- Note : Run this script while connected as the SYS user PROMPT ################################################################# PROMPT -- 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 tablesNoIndexesInfo_&s_dbname._&s_machine ttitle left &s_curDate - center "Tables without Indexes in " &s_dbname " on " &s_machine skip 2 break on owner skip 2 select owner, table_name from dba_tables where owner NOT IN ('SYS', 'SYSTEM') minus select owner, table_name from dba_indexes where owner NOT IN ('SYS', 'SYSTEM') order by owner; ttitle left &s_curDate - center "Tables without Primary Key in " &s_dbname " on " &s_machine skip 2 select owner, table_name from dba_tables where owner NOT IN ('SYS', 'SYSTEM') minus select owner, table_name from dba_constraints where constraint_type = 'P' and owner NOT IN ('SYS', 'SYSTEM') order by owner; 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 table without indexes information was found for the database &s_dbname PROMPT PROMPT PROMPT Output file tablesNoIndexesInfo_&s_dbname._&s_machine..LST produced PROMPT @sqlplus_settings