├── 10g ├── active_session_waits.sql ├── ash.sql ├── db_usage_hwm.sql ├── dynamic_memory.sql ├── event_histogram.sql ├── feature_usage.sql ├── flashback_db_info.sql ├── generate_multiple_awr_reports.sql ├── job_chain_rules.sql ├── job_chain_steps.sql ├── job_chains.sql ├── job_classes.sql ├── job_programs.sql ├── job_running_chains.sql ├── job_schedules.sql ├── jobs.sql ├── jobs_running.sql ├── lock_tree.sql ├── scheduler_attributes.sql ├── segment_advisor.sql ├── services.sql ├── session_waits.sql ├── sga_buffers.sql ├── sga_dynamic_components.sql ├── sga_dynamic_free_memory.sql ├── sga_resize_ops.sql ├── sysaux_occupants.sql ├── test_calendar_string.sql ├── window_groups.sql └── windows.sql ├── 11g ├── admin_privs.sql ├── autotask_change_window_schedules.sql ├── autotask_job_history.sql ├── autotask_schedule.sql ├── default_passwords.sql ├── diag_info.sql ├── extended_stats.sql ├── fda.sql ├── fda_tables.sql ├── fda_ts.sql ├── identify_trace_file.sql ├── job_credentials.sql ├── job_output_file.sql ├── job_run_details.sql ├── memory_dynamic_components.sql ├── memory_resize_ops.sql ├── memory_target_advice.sql ├── network_acl_privileges.sql ├── network_acls.sql ├── result_cache_objects.sql ├── result_cache_report.sql ├── result_cache_statistics.sql ├── result_cache_status.sql ├── session_fix.sql ├── statistics_global_prefs.sql ├── system_fix.sql ├── system_fix_count.sql └── temp_free_space.sql ├── 12c ├── cdb_resource_plan_directives.sql ├── cdb_resource_plans.sql ├── cdb_resource_profile_directives.sql ├── credentials.sql ├── host_aces.sql ├── host_acls.sql ├── login.sql ├── pdbs.sql ├── plugin_violations.sql ├── priv_captures.sql ├── redaction_columns.sql ├── redaction_policies.sql ├── redaction_value_defaults.sql └── services.sql ├── README.md ├── constraints ├── disable_chk.sql ├── disable_fk.sql ├── disable_pk.sql ├── disable_ref_fk.sql ├── enable_chk.sql ├── enable_fk.sql ├── enable_pk.sql └── enable_ref_fk.sql ├── download.rb ├── index.htm ├── miscellaneous ├── analyze_all.sql ├── base64decode.sql ├── base64encode.sql ├── blob_to_clob.sql ├── clob_to_blob.sql ├── column_comments.sql ├── comments.sql ├── compile_all.sql ├── compile_all_bodies.sql ├── compile_all_funcs.sql ├── compile_all_procs.sql ├── compile_all_specs.sql ├── compile_all_trigs.sql ├── compile_all_views.sql ├── conversion_api.sql ├── csv.sql ├── date_api.sql ├── dict_comments.sql ├── digest_auth_api.sql ├── drop_all.sql ├── dsp.pkb ├── dsp.pks ├── err.pkb ├── err.pks ├── find_object.sql ├── ftp.pkb ├── ftp.pks ├── gen_health.sql ├── get_pivot.sql ├── login.sql ├── part_hv_to_date.sql ├── proc_defs.sql ├── rebuild_index.sql ├── smart_quotes_api.sql ├── soap_api.sql ├── string_agg.sql ├── string_api.sql ├── switch_schema.sql ├── table_comments.sql ├── table_defs.sql ├── table_differences.sql ├── trc.pkb ├── trc.pks └── ts_move_api.sql ├── monitoring ├── access.sql ├── active_sessions.sql ├── cache_hit_ratio.sql ├── call_stack.sql ├── code_dep.sql ├── code_dep_distinct.sql ├── code_dep_on.sql ├── code_dep_tree.sql ├── column_defaults.sql ├── controlfiles.sql ├── datafiles.sql ├── db_cache_advice.sql ├── db_info.sql ├── db_links.sql ├── db_links_open.sql ├── db_properties.sql ├── df_free_space.sql ├── directories.sql ├── directory_permissions.sql ├── dispatchers.sql ├── error_stack.sql ├── errors.sql ├── explain.sql ├── file_io.sql ├── fk_columns.sql ├── fks.sql ├── free_space.sql ├── health.sql ├── hidden_parameters.sql ├── high_water_mark.sql ├── hot_blocks.sql ├── identify_trace_file.sql ├── index_extents.sql ├── index_monitoring_status.sql ├── index_partitions.sql ├── index_usage.sql ├── invalid_objects.sql ├── jobs.sql ├── jobs_running.sql ├── large_lob_segments.sql ├── large_segments.sql ├── latch_hit_ratios.sql ├── latch_holders.sql ├── latches.sql ├── library_cache.sql ├── license.sql ├── locked_objects.sql ├── locked_objects_internal.sql ├── logfiles.sql ├── longops.sql ├── lru_latch_ratio.sql ├── max_extents.sql ├── min_datafile_size.sql ├── monitor.sql ├── monitor_memory.sql ├── monitoring_status.sql ├── nls_params.sql ├── non_indexed_fks.sql ├── obj_lock.sql ├── object_privs.sql ├── object_status.sql ├── objects.sql ├── open_cursors.sql ├── open_cursors_by_sid.sql ├── open_cursors_full_by_sid.sql ├── options.sql ├── param_valid_values.sql ├── parameter_diffs.sql ├── parameters.sql ├── parameters_non_default.sql ├── part_tables.sql ├── pga_target_advice.sql ├── pipes.sql ├── profiler_run_details.sql ├── profiler_runs.sql ├── profiles.sql ├── rbs_extents.sql ├── rbs_stats.sql ├── recovery_status.sql ├── recyclebin.sql ├── redo_by_day.sql ├── redo_by_hour.sql ├── redo_by_min.sql ├── registry_history.sql ├── role_privs.sql ├── roles.sql ├── search_source.sql ├── segment_size.sql ├── segment_stats.sql ├── session_events.sql ├── session_events_by_sid.sql ├── session_events_by_spid.sql ├── session_io.sql ├── session_pga.sql ├── session_rollback.sql ├── session_stats.sql ├── session_stats_by_sid.sql ├── session_undo.sql ├── session_waits.sql ├── sessions.sql ├── sessions_by_machine.sql ├── show_indexes.sql ├── show_space.sql ├── show_tables.sql ├── source.sql ├── spfile_parameters.sql ├── sql_area.sql ├── sql_text.sql ├── sql_text_by_sid.sql ├── statistics_prefs.sql ├── synonyms_to_missing_objects.sql ├── system_events.sql ├── system_parameters.sql ├── system_privs.sql ├── system_stats.sql ├── table_dep.sql ├── table_extents.sql ├── table_indexes.sql ├── table_partitions.sql ├── table_stats.sql ├── table_triggers.sql ├── tables_with_locked_stats.sql ├── tables_with_zero_rows.sql ├── tablespaces.sql ├── temp_extent_map.sql ├── temp_free_space.sql ├── temp_io.sql ├── temp_segments.sql ├── temp_usage.sql ├── tempfiles.sql ├── tempseg_usage.sql ├── top_latches.sql ├── top_sessions.sql ├── top_sql.sql ├── trace_run_details.sql ├── trace_runs.sql ├── ts_datafiles.sql ├── ts_extent_map.sql ├── ts_free_space.sql ├── ts_full.sql ├── ts_thresholds.sql ├── ts_thresholds_reset.sql ├── ts_thresholds_set_default.sql ├── tuning.sql ├── unusable_indexes.sql ├── unused_space.sql ├── user_hit_ratio.sql ├── user_roles.sql ├── user_system_privs.sql ├── user_temp_space.sql ├── user_undo_space.sql ├── users.sql ├── users_with_role.sql └── users_with_sys_priv.sql ├── rac ├── locked_objects_rac.sql ├── longops_rac.sql ├── monitor_memory_rac.sql ├── session_undo_rac.sql ├── session_waits_rac.sql └── sessions_rac.sql ├── resource_manager ├── active_plan.sql ├── consumer_group_usage.sql ├── consumer_groups.sql ├── plan_directives.sql └── resource_plans.sql ├── script_creation ├── backup.sql ├── build_api.sql ├── build_api2.sql ├── create_data.sql ├── db_link_ddl.sql ├── directory_ddl.sql ├── drop_cons_on_table.sql ├── drop_fks_on_table.sql ├── drop_fks_ref_table.sql ├── drop_indexes.sql ├── fks_on_table_ddl.sql ├── fks_ref_table_ddl.sql ├── index_monitoring_off.sql ├── index_monitoring_on.sql ├── logon_as_user.sql ├── logon_as_user_orig.sql ├── monitoring_off.sql ├── monitoring_on.sql ├── network_acls_ddl.sql ├── object_grants.sql ├── profile_ddl.sql ├── rbs_structure.sql ├── recreate_table.sql ├── role_ddl.sql ├── sequence_ddl.sql ├── synonym_by_object_owner_ddl.sql ├── synonym_ddl.sql ├── synonym_public_remote_ddl.sql ├── table_constraints_ddl.sql ├── table_ddl.sql ├── table_grants_ddl.sql ├── table_indexes_ddl.sql ├── table_triggers_ddl.sql ├── tablespace_ddl.sql ├── tablespace_structure.sql ├── trigger_ddl.sql ├── user_ddl.sql └── view_ddl.sql ├── security ├── grant_delete.sql ├── grant_execute.sql ├── grant_insert.sql ├── grant_select.sql ├── grant_update.sql ├── package_synonyms.sql ├── schema_write_access.sql ├── sequence_synonyms.sql ├── table_synonyms.sql └── view_synonyms.sql └── weblogic ├── deploy_app.py.txt ├── deploy_app.sh ├── start-domain.sh ├── start-forms-reports.sh ├── start-node-manager.sh ├── stop-domain.sh ├── stop-forms-reports.sh └── stop-node-manager.sh /10g/ash.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/ash.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the minutes spent on each event for the specified time. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @active_session_waits (mins) 8 | -- Last Modified: 21/12/2004 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET VERIFY OFF 12 | 13 | SELECT NVL(a.event, 'ON CPU') AS event, 14 | COUNT(*) AS total_wait_time 15 | FROM v$active_session_history a 16 | WHERE a.sample_time > SYSDATE - &1/(24*60) 17 | GROUP BY a.event 18 | ORDER BY total_wait_time DESC; 19 | 20 | SET VERIFY ON -------------------------------------------------------------------------------- /10g/db_usage_hwm.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/db_usage_hwm.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays high water mark statistics. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @db_usage_hwm 8 | -- Last Modified: 26-NOV-2004 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | COLUMN name FORMAT A40 12 | COLUMN highwater FORMAT 999999999999 13 | COLUMN last_value FORMAT 999999999999 14 | SET PAGESIZE 24 15 | 16 | SELECT hwm1.name, 17 | hwm1.highwater, 18 | hwm1.last_value 19 | FROM dba_high_water_mark_statistics hwm1 20 | WHERE hwm1.version = (SELECT MAX(hwm2.version) 21 | FROM dba_high_water_mark_statistics hwm2 22 | WHERE hwm2.name = hwm1.name) 23 | ORDER BY hwm1.name; 24 | 25 | COLUMN FORMAT DEFAULT 26 | -------------------------------------------------------------------------------- /10g/dynamic_memory.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/dynamic_memory.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the values of the dynamically memory pools. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @dynamic_memory 8 | -- Last Modified: 08-NOV-2004 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | COLUMN name FORMAT A40 12 | COLUMN value FORMAT A40 13 | 14 | SELECT name, 15 | value 16 | FROM v$parameter 17 | WHERE SUBSTR(name, 1, 1) = '_' 18 | ORDER BY name; 19 | 20 | COLUMN FORMAT DEFAULT 21 | -------------------------------------------------------------------------------- /10g/event_histogram.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/event_histogram.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays histogram of the event waits times. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @event_histogram "(event-name)" 8 | -- Last Modified: 08-NOV-2005 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET VERIFY OFF 12 | COLUMN event FORMAT A30 13 | 14 | SELECT event#, 15 | event, 16 | wait_time_milli, 17 | wait_count 18 | FROM v$event_histogram 19 | WHERE event LIKE '%&1%' 20 | ORDER BY event, wait_time_milli; 21 | 22 | COLUMN FORMAT DEFAULT 23 | SET VERIFY ON -------------------------------------------------------------------------------- /10g/feature_usage.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/feature_usage.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays feature usage statistics. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @feature_usage 8 | -- Last Modified: 26-NOV-2004 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | COLUMN name FORMAT A60 12 | COLUMN detected_usages FORMAT 999999999999 13 | 14 | SELECT u1.name, 15 | u1.detected_usages, 16 | u1.currently_used, 17 | u1.version 18 | FROM dba_feature_usage_statistics u1 19 | WHERE u1.version = (SELECT MAX(u2.version) 20 | FROM dba_feature_usage_statistics u2 21 | WHERE u2.name = u1.name) 22 | AND u1.detected_usages > 0 23 | AND u1.dbid = (SELECT dbid FROM v$database) 24 | ORDER BY u1.name; 25 | 26 | COLUMN FORMAT DEFAULT -------------------------------------------------------------------------------- /10g/job_chain_rules.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/job_chain_rules.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays scheduler information about job chain rules. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @job_chain_rules 8 | -- Last Modified: 26/10/2011 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | COLUMN owner FORMAT A10 12 | COLUMN chain_name FORMAT A15 13 | COLUMN rule_owner FORMAT A10 14 | COLUMN rule_name FORMAT A15 15 | COLUMN condition FORMAT A25 16 | COLUMN action FORMAT A20 17 | COLUMN comments FORMAT A25 18 | 19 | SELECT owner, 20 | chain_name, 21 | rule_owner, 22 | rule_name, 23 | condition, 24 | action, 25 | comments 26 | FROM dba_scheduler_chain_rules 27 | ORDER BY owner, chain_name, rule_owner, rule_name; -------------------------------------------------------------------------------- /10g/job_chain_steps.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/job_chain_steps.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays scheduler information about job chain steps. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @job_chain_steps 8 | -- Last Modified: 26/10/2011 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | COLUMN owner FORMAT A10 12 | COLUMN chain_name FORMAT A15 13 | COLUMN step_name FORMAT A15 14 | COLUMN program_owner FORMAT A10 15 | COLUMN program_name FORMAT A15 16 | 17 | SELECT owner, 18 | chain_name, 19 | step_name, 20 | program_owner, 21 | program_name, 22 | step_type 23 | FROM dba_scheduler_chain_steps 24 | ORDER BY owner, chain_name, step_name; -------------------------------------------------------------------------------- /10g/job_chains.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/job_chains.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays scheduler information about job chains. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @job_chains 8 | -- Last Modified: 26/10/2011 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | COLUMN owner FORMAT A10 12 | COLUMN chain_name FORMAT A15 13 | COLUMN rule_set_owner FORMAT A10 14 | COLUMN rule_set_name FORMAT A15 15 | COLUMN comments FORMAT A15 16 | 17 | SELECT owner, 18 | chain_name, 19 | rule_set_owner, 20 | rule_set_name, 21 | number_of_rules, 22 | number_of_steps, 23 | enabled, 24 | comments 25 | FROM dba_scheduler_chains; -------------------------------------------------------------------------------- /10g/job_classes.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/job_classes.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays scheduler information about job classes. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @job_classes 8 | -- Last Modified: 27/07/2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | 12 | COLUMN service FORMAT A20 13 | COLUMN comments FORMAT A40 14 | 15 | SELECT job_class_name, 16 | resource_consumer_group, 17 | service, 18 | logging_level, 19 | log_history, 20 | comments 21 | FROM dba_scheduler_job_classes 22 | ORDER BY job_class_name; 23 | -------------------------------------------------------------------------------- /10g/job_programs.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/job_programs.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays scheduler information about job programs. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @job_programs 8 | -- Last Modified: 27/07/2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 250 11 | 12 | COLUMN owner FORMAT A20 13 | COLUMN program_name FORMAT A30 14 | COLUMN program_action FORMAT A50 15 | COLUMN comments FORMAT A40 16 | 17 | SELECT owner, 18 | program_name, 19 | program_type, 20 | program_action, 21 | number_of_arguments, 22 | enabled, 23 | comments 24 | FROM dba_scheduler_programs 25 | ORDER BY owner, program_name; 26 | -------------------------------------------------------------------------------- /10g/job_running_chains.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/job_running_chains.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays scheduler information about job running chains. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @job_running_chains.sql 8 | -- Last Modified: 26/10/2011 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | COLUMN owner FORMAT A10 12 | COLUMN job_name FORMAT A20 13 | COLUMN chain_owner FORMAT A10 14 | COLUMN chain_name FORMAT A15 15 | COLUMN step_name FORMAT A25 16 | 17 | SELECT owner, 18 | job_name, 19 | chain_owner, 20 | chain_name, 21 | step_name, 22 | state 23 | FROM dba_scheduler_running_chains 24 | ORDER BY owner, job_name, chain_name, step_name; -------------------------------------------------------------------------------- /10g/job_schedules.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/job_schedules.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays scheduler information about job schedules. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @job_schedules 8 | -- Last Modified: 27/07/2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 250 11 | 12 | COLUMN owner FORMAT A20 13 | COLUMN schedule_name FORMAT A30 14 | COLUMN start_date FORMAT A35 15 | COLUMN repeat_interval FORMAT A50 16 | COLUMN end_date FORMAT A35 17 | COLUMN comments FORMAT A40 18 | 19 | SELECT owner, 20 | schedule_name, 21 | start_date, 22 | repeat_interval, 23 | end_date, 24 | comments 25 | FROM dba_scheduler_schedules 26 | ORDER BY owner, schedule_name; 27 | -------------------------------------------------------------------------------- /10g/jobs.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/jobs.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays scheduler job information. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @jobs 8 | -- Last Modified: 27/07/2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | 12 | COLUMN owner FORMAT A20 13 | COLUMN job_name FORMAT A30 14 | COLUMN job_class FORMAT A30 15 | COLUMN next_run_date FORMAT A36 16 | 17 | SELECT owner, 18 | job_name, 19 | enabled, 20 | job_class, 21 | next_run_date 22 | FROM dba_scheduler_jobs 23 | ORDER BY owner, job_name; 24 | -------------------------------------------------------------------------------- /10g/jobs_running.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/jobs_running.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays scheduler information for running jobs. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @jobs_running 8 | -- Last Modified: 27/07/2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | 12 | COLUMN owner FORMAT A20 13 | COLUMN elapsed_time FORMAT A30 14 | 15 | SELECT owner, 16 | job_name, 17 | running_instance, 18 | elapsed_time, 19 | session_id 20 | FROM dba_scheduler_running_jobs 21 | ORDER BY owner, job_name; -------------------------------------------------------------------------------- /10g/services.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/services.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about database services. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @services 8 | -- Last Modified: 05/11/2004 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | COLUMN name FORMAT A30 12 | COLUMN network_name FORMAT A50 13 | 14 | SELECT name, 15 | network_name 16 | FROM dba_services 17 | ORDER BY name; -------------------------------------------------------------------------------- /10g/session_waits.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/session_waits.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information on all database session waits. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @session_waits 8 | -- Last Modified: 11/03/2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | SET PAGESIZE 1000 12 | 13 | COLUMN username FORMAT A20 14 | COLUMN event FORMAT A30 15 | COLUMN wait_class FORMAT A15 16 | 17 | SELECT NVL(s.username, '(oracle)') AS username, 18 | s.sid, 19 | s.serial#, 20 | sw.event, 21 | sw.wait_class, 22 | sw.wait_time, 23 | sw.seconds_in_wait, 24 | sw.state 25 | FROM v$session_wait sw, 26 | v$session s 27 | WHERE s.sid = sw.sid 28 | ORDER BY sw.seconds_in_wait DESC; 29 | -------------------------------------------------------------------------------- /10g/sga_dynamic_components.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/sga_dynamic_components.sql 4 | -- Author : Tim Hall 5 | -- Description : Provides information about dynamic SGA components. 6 | -- Requirements : Access to the v$ views. 7 | -- Call Syntax : @sga_dynamic_components 8 | -- Last Modified: 09/05/2017 9 | -- ----------------------------------------------------------------------------------- 10 | COLUMN component FORMAT A30 11 | 12 | SELECT component, 13 | ROUND(current_size/1024/1024) AS current_size_mb, 14 | ROUND(min_size/1024/1024) AS min_size_mb, 15 | ROUND(max_size/1024/1024) AS max_size_mb 16 | FROM v$sga_dynamic_components 17 | WHERE current_size != 0 18 | ORDER BY component; 19 | -------------------------------------------------------------------------------- /10g/sga_dynamic_free_memory.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/sga_dynamic_free_memory.sql 4 | -- Author : Tim Hall 5 | -- Description : Provides information about free memory in the SGA. 6 | -- Requirements : Access to the v$ views. 7 | -- Call Syntax : @sga_dynamic_free_memory 8 | -- Last Modified: 23/08/2008 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SELECT * 12 | FROM v$sga_dynamic_free_memory; 13 | -------------------------------------------------------------------------------- /10g/sga_resize_ops.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/sga_resize_ops.sql 4 | -- Author : Tim Hall 5 | -- Description : Provides information about memory resize operations. 6 | -- Requirements : Access to the v$ views. 7 | -- Call Syntax : @sga_resize_ops 8 | -- Last Modified: 09/05/2017 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET LINESIZE 200 12 | 13 | COLUMN parameter FORMAT A25 14 | 15 | SELECT start_time, 16 | end_time, 17 | component, 18 | oper_type, 19 | oper_mode, 20 | parameter, 21 | ROUND(initial_size/1024/1024) AS initial_size_mb, 22 | ROUND(target_size/1024/1024) AS target_size_mb, 23 | ROUND(final_size/1024/1024) AS final_size_mb, 24 | status 25 | FROM v$sga_resize_ops 26 | ORDER BY start_time; 27 | -------------------------------------------------------------------------------- /10g/sysaux_occupants.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/sysaux_occupants.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about the contents of the SYSAUX tablespace. 6 | -- Requirements : Access to the v$ views. 7 | -- Call Syntax : @sysaux_occupants 8 | -- Last Modified: 27/07/2005 9 | -- ----------------------------------------------------------------------------------- 10 | COLUMN occupant_name FORMAT A30 11 | COLUMN schema_name FORMAT A20 12 | 13 | SELECT occupant_name, 14 | schema_name, 15 | space_usage_kbytes 16 | FROM v$sysaux_occupants 17 | ORDER BY occupant_name; 18 | -------------------------------------------------------------------------------- /10g/window_groups.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/window_groups.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays scheduler information about window groups. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @window_groups 8 | -- Last Modified: 05/11/2004 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 250 11 | 12 | COLUMN comments FORMAT A40 13 | 14 | SELECT window_group_name, 15 | enabled, 16 | number_of_windows, 17 | comments 18 | FROM dba_scheduler_window_groups 19 | ORDER BY window_group_name; 20 | 21 | SELECT window_group_name, 22 | window_name 23 | FROM dba_scheduler_wingroup_members 24 | ORDER BY window_group_name, window_name; 25 | -------------------------------------------------------------------------------- /10g/windows.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/windows.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays scheduler information about windows. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @windows 8 | -- Last Modified: 05/11/2004 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 250 11 | 12 | COLUMN comments FORMAT A40 13 | 14 | SELECT window_name, 15 | resource_plan, 16 | enabled, 17 | active, 18 | comments 19 | FROM dba_scheduler_windows 20 | ORDER BY window_name; 21 | -------------------------------------------------------------------------------- /11g/admin_privs.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/admin_privs.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the users who currently have admin privileges. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @min_datafile_size 8 | -- Last Modified: 30/11/2011 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SELECT * 12 | FROM v$pwfile_users 13 | ORDER BY username; -------------------------------------------------------------------------------- /11g/autotask_job_history.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/autotask_job_history.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the job history for the automatic maintenance tasks. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @autotask_job_history.sql 8 | -- Last Modified: 14-JUL-2016 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | COLUMN client_name FORMAT A40 12 | COLUMN window_name FORMAT A20 13 | COLUMN job_start_time FORMAT A40 14 | COLUMN job_duration FORMAT A20 15 | COLUMN job_status FORMAT A10 16 | 17 | SELECT client_name, 18 | window_name, 19 | job_start_time, 20 | job_duration, 21 | job_status, 22 | job_error 23 | FROM dba_autotask_job_history 24 | ORDER BY job_start_time; 25 | 26 | COLUMN FORMAT DEFAULT 27 | -------------------------------------------------------------------------------- /11g/autotask_schedule.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/autotask_schedule.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the window schedule the automatic maintenance tasks. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @autotask_schedule.sql 8 | -- Last Modified: 14-JUL-2016 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | COLUMN window_name FORMAT A20 12 | COLUMN start_time FORMAT A40 13 | COLUMN duration FORMAT A20 14 | 15 | SELECT * 16 | FROM dba_autotask_schedule 17 | ORDER BY start_time; 18 | 19 | 20 | COLUMN FORMAT DEFAULT 21 | -------------------------------------------------------------------------------- /11g/default_passwords.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/default_passwords.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays users with default passwords. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @default_passwords 8 | -- Last Modified: 26-NOV-2011 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SELECT a.username, b.account_status 12 | FROM dba_users_with_defpwd a 13 | JOIN dba_users b ON a.username = b.username 14 | ORDER BY 1; 15 | -------------------------------------------------------------------------------- /11g/diag_info.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/diag_info.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the contents of the v$diag_info view. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @diag_info 8 | -- Last Modified: 23/08/2008 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | COLUMN name FORMAT A30 12 | COLUMN value FORMAT A110 13 | 14 | SELECT * 15 | FROM v$diag_info; 16 | -------------------------------------------------------------------------------- /11g/extended_stats.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/extended_stats.sql 4 | -- Author : Tim Hall 5 | -- Description : Provides information about extended statistics. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @extended_stats 8 | -- Last Modified: 30/11/2011 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | COLUMN owner FORMAT A20 12 | COLUMN extension_name FORMAT A15 13 | COLUMN extension FORMAT A50 14 | 15 | SELECT owner, table_name, extension_name, extension 16 | FROM dba_stat_extensions 17 | ORDER by owner, table_name; -------------------------------------------------------------------------------- /11g/fda.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/fda.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about flashback data archives. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @fda 8 | -- Last Modified: 06-JAN-2015 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET LINESIZE 150 12 | 13 | COLUMN owner_name FORMAT A20 14 | COLUMN flashback_archive_name FORMAT A22 15 | COLUMN create_time FORMAT A20 16 | COLUMN last_purge_time FORMAT A20 17 | 18 | SELECT owner_name, 19 | flashback_archive_name, 20 | flashback_archive#, 21 | retention_in_days, 22 | TO_CHAR(create_time, 'DD-MON-YYYY HH24:MI:SS') AS create_time, 23 | TO_CHAR(last_purge_time, 'DD-MON-YYYY HH24:MI:SS') AS last_purge_time, 24 | status 25 | FROM dba_flashback_archive 26 | ORDER BY owner_name, flashback_archive_name; 27 | -------------------------------------------------------------------------------- /11g/fda_tables.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/fda_tables.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about flashback data archives. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @fda_tables 8 | -- Last Modified: 06-JAN-2015 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET LINESIZE 150 12 | 13 | COLUMN owner_name FORMAT A20 14 | COLUMN table_name FORMAT A20 15 | COLUMN flashback_archive_name FORMAT A22 16 | COLUMN archive_table_name FORMAT A20 17 | 18 | SELECT owner_name, 19 | table_name, 20 | flashback_archive_name, 21 | archive_table_name, 22 | status 23 | FROM dba_flashback_archive_tables 24 | ORDER BY owner_name, table_name; 25 | -------------------------------------------------------------------------------- /11g/fda_ts.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/fda_ts.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about flashback data archives. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @fda_ts 8 | -- Last Modified: 06-JAN-2015 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET LINESIZE 150 12 | 13 | COLUMN flashback_archive_name FORMAT A22 14 | COLUMN tablespace_name FORMAT A20 15 | COLUMN quota_in_mb FORMAT A11 16 | 17 | SELECT flashback_archive_name, 18 | flashback_archive#, 19 | tablespace_name, 20 | quota_in_mb 21 | FROM dba_flashback_archive_ts 22 | ORDER BY flashback_archive_name; 23 | -------------------------------------------------------------------------------- /11g/identify_trace_file.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/identify_trace_file.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the name of the trace file associated with the current session. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @identify_trace_file 8 | -- Last Modified: 23/08/2008 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 100 11 | COLUMN value FORMAT A60 12 | 13 | SELECT value 14 | FROM v$diag_info 15 | WHERE name = 'Default Trace File'; -------------------------------------------------------------------------------- /11g/job_credentials.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/job_credentials.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays scheduler information about job credentials. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @job_credentials 8 | -- Last Modified: 23/08/2008 9 | -- ----------------------------------------------------------------------------------- 10 | COLUMN credential_name FORMAT A25 11 | COLUMN username FORMAT A20 12 | COLUMN windows_domain FORMAT A20 13 | 14 | SELECT credential_name, 15 | username, 16 | windows_domain 17 | FROM dba_scheduler_credentials 18 | ORDER BY credential_name; 19 | -------------------------------------------------------------------------------- /11g/memory_dynamic_components.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/memory_dynamic_components.sql 4 | -- Author : Tim Hall 5 | -- Description : Provides information about dynamic memory components. 6 | -- Requirements : Access to the v$ views. 7 | -- Call Syntax : @memory_dynamic_components 8 | -- Last Modified: 09/05/2017 9 | -- ----------------------------------------------------------------------------------- 10 | COLUMN component FORMAT A30 11 | 12 | SELECT component, 13 | ROUND(current_size/1024/1024) AS current_size_mb, 14 | ROUND(min_size/1024/1024) AS min_size_mb, 15 | ROUND(max_size/1024/1024) AS max_size_mb 16 | FROM v$memory_dynamic_components 17 | WHERE current_size != 0 18 | ORDER BY component; 19 | -------------------------------------------------------------------------------- /11g/memory_resize_ops.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/memory_resize_ops.sql 4 | -- Author : Tim Hall 5 | -- Description : Provides information about memory resize operations. 6 | -- Requirements : Access to the v$ views. 7 | -- Call Syntax : @memory_resize_ops 8 | -- Last Modified: 09/05/2017 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET LINESIZE 200 12 | 13 | COLUMN parameter FORMAT A25 14 | 15 | SELECT start_time, 16 | end_time, 17 | component, 18 | oper_type, 19 | oper_mode, 20 | parameter, 21 | ROUND(initial_size/1024/1024) AS initial_size_mb, 22 | ROUND(target_size/1024/1024) AS target_size_mb, 23 | ROUND(final_size/1024/1024) AS final_size_mb, 24 | status 25 | FROM v$memory_resize_ops 26 | ORDER BY start_time; 27 | -------------------------------------------------------------------------------- /11g/memory_target_advice.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/memory_target_advice.sql 4 | -- Author : Tim Hall 5 | -- Description : Provides information to help tune the MEMORY_TARGET parameter. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @memory_target_advice 8 | -- Last Modified: 23/08/2008 9 | -- ----------------------------------------------------------------------------------- 10 | SELECT * 11 | FROM v$memory_target_advice 12 | ORDER BY memory_size; -------------------------------------------------------------------------------- /11g/network_acl_privileges.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/network_acl_privileges.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays privileges for the network ACLs. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @network_acl_privileges 8 | -- Last Modified: 30/11/2011 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 150 11 | 12 | COLUMN acl FORMAT A50 13 | COLUMN principal FORMAT A20 14 | COLUMN privilege FORMAT A10 15 | 16 | SELECT acl, 17 | principal, 18 | privilege, 19 | is_grant, 20 | TO_CHAR(start_date, 'DD-MON-YYYY') AS start_date, 21 | TO_CHAR(end_date, 'DD-MON-YYYY') AS end_date 22 | FROM dba_network_acl_privileges 23 | ORDER BY acl, principal, privilege; 24 | 25 | SET LINESIZE 80 26 | -------------------------------------------------------------------------------- /11g/network_acls.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/network_acls.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about network ACLs. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @network_acls 8 | -- Last Modified: 30/11/2011 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 150 11 | 12 | COLUMN host FORMAT A40 13 | COLUMN acl FORMAT A50 14 | 15 | SELECT host, lower_port, upper_port, acl 16 | FROM dba_network_acls 17 | ORDER BY host; 18 | 19 | SET LINESIZE 80 -------------------------------------------------------------------------------- /11g/result_cache_objects.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/result_cache_objects.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about the objects in the result cache. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @result_cache_objects 8 | -- Last Modified: 07/11/2012 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 1000 11 | 12 | SELECT * 13 | FROM v$result_cache_objects; 14 | -------------------------------------------------------------------------------- /11g/result_cache_report.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/result_cache_report.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the result cache report. 6 | -- Requirements : Access to the DBMS_RESULT_CACHE package. 7 | -- Call Syntax : @result_cache_report 8 | -- Last Modified: 07/11/2012 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET SERVEROUTPUT ON 12 | EXEC DBMS_RESULT_CACHE.memory_report(detailed => true); 13 | -------------------------------------------------------------------------------- /11g/result_cache_statistics.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/result_cache_statistics.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays result cache statistics. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @result_cache_statistics 8 | -- Last Modified: 07/11/2012 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | COLUMN name FORMAT A30 12 | COLUMN value FORMAT A30 13 | 14 | SELECT id, 15 | name, 16 | value 17 | FROM v$result_cache_statistics 18 | ORDER BY id; 19 | 20 | CLEAR COLUMNS -------------------------------------------------------------------------------- /11g/result_cache_status.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/result_cache_status.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the status of the result cache. 6 | -- Requirements : Access to the DBMS_RESULT_CACHE package. 7 | -- Call Syntax : @result_cache_status 8 | -- Last Modified: 07/11/2012 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SELECT DBMS_RESULT_CACHE.status FROM dual; -------------------------------------------------------------------------------- /11g/session_fix.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/session_fix.sql 4 | -- Author : Tim Hall 5 | -- Description : Provides information about session fixes for the specified phrase and version. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @session_fix (session_id | all) (phrase | all) (version | all) 8 | -- Last Modified: 30/11/2011 9 | -- ----------------------------------------------------------------------------------- 10 | SET VERIFY OFF 11 | SET LINESIZE 300 12 | 13 | COLUMN sql_feature FORMAT A35 14 | COLUMN optimizer_feature_enable FORMAT A9 15 | 16 | SELECT * 17 | FROM v$session_fix_control 18 | WHERE session_id = DECODE('&1', 'all', session_id, '&1') 19 | AND LOWER(description) LIKE DECODE('&2', 'all', '%', '%&2%') 20 | AND optimizer_feature_enable = DECODE('&3', 'all', optimizer_feature_enable, '&3'); -------------------------------------------------------------------------------- /11g/system_fix.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/system_fix.sql 4 | -- Author : Tim Hall 5 | -- Description : Provides information about system fixes for the specified phrase and version. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @system_fix (phrase | all) (version | all) 8 | -- Last Modified: 30/11/2011 9 | -- ----------------------------------------------------------------------------------- 10 | SET VERIFY OFF 11 | SET LINESIZE 300 12 | 13 | COLUMN sql_feature FORMAT A35 14 | COLUMN optimizer_feature_enable FORMAT A9 15 | 16 | SELECT * 17 | FROM v$system_fix_control 18 | WHERE LOWER(description) LIKE DECODE('&1', 'all', '%', '%&1%') 19 | AND optimizer_feature_enable = DECODE('&2', 'all', optimizer_feature_enable, '&2'); -------------------------------------------------------------------------------- /11g/system_fix_count.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/system_fix_count.sql 4 | -- Author : Tim Hall 5 | -- Description : Provides information about system fixes per version. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @system_fix_count 8 | -- Last Modified: 30/11/2011 9 | -- ----------------------------------------------------------------------------------- 10 | SELECT optimizer_feature_enable, 11 | COUNT(*) 12 | FROM v$system_fix_control 13 | GROUP BY optimizer_feature_enable 14 | ORDER BY optimizer_feature_enable; -------------------------------------------------------------------------------- /11g/temp_free_space.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/11g/temp_free_space.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about temporary tablespace usage. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @temp_free_space 8 | -- Last Modified: 23-AUG-2008 9 | -- ----------------------------------------------------------------------------------- 10 | SELECT * 11 | FROM dba_temp_free_space; -------------------------------------------------------------------------------- /12c/cdb_resource_plan_directives.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/12c/cdb_resource_plan_directives.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays CDB resource plan directives. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @cdb_resource_plan_directives.sql (plan-name or all) 8 | -- Last Modified: 22-MAR-2014 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | COLUMN plan FORMAT A30 12 | COLUMN pluggable_database FORMAT A25 13 | SET LINESIZE 100 VERIFY OFF 14 | 15 | SELECT plan, 16 | pluggable_database, 17 | shares, 18 | utilization_limit AS util, 19 | parallel_server_limit AS parallel 20 | FROM dba_cdb_rsrc_plan_directives 21 | WHERE plan = DECODE(UPPER('&1'), 'ALL', plan, UPPER('&1')) 22 | ORDER BY plan, pluggable_database; 23 | 24 | SET VERIFY ON -------------------------------------------------------------------------------- /12c/cdb_resource_plans.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/12c/cdb_resource_plans.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays CDB resource plans. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @cdb_resource_plans.sql 8 | -- Last Modified: 22-MAR-2014 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | COLUMN plan FORMAT A30 12 | COLUMN comments FORMAT A30 13 | COLUMN status FORMAT A10 14 | SET LINESIZE 100 15 | 16 | SELECT plan_id, 17 | plan, 18 | comments, 19 | status, 20 | mandatory 21 | FROM dba_cdb_rsrc_plans 22 | ORDER BY plan; 23 | -------------------------------------------------------------------------------- /12c/cdb_resource_profile_directives.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/12c/cdb_resource_profile_directives.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays CDB resource profile directives. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @cdb_resource_profile_directives.sql (plan-name or all) 8 | -- Last Modified: 10-JAN-2017 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | COLUMN plan FORMAT A30 12 | COLUMN pluggable_database FORMAT A25 13 | COLUMN profile FORMAT A25 14 | SET LINESIZE 150 VERIFY OFF 15 | 16 | SELECT plan, 17 | pluggable_database, 18 | profile, 19 | shares, 20 | utilization_limit AS util, 21 | parallel_server_limit AS parallel 22 | FROM dba_cdb_rsrc_plan_directives 23 | WHERE plan = DECODE(UPPER('&1'), 'ALL', plan, UPPER('&1')) 24 | ORDER BY plan, pluggable_database, profile; 25 | 26 | SET VERIFY ON -------------------------------------------------------------------------------- /12c/credentials.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/12c/credentials.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about credentials. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @credentials 8 | -- Last Modified: 18/12/2013 9 | -- ----------------------------------------------------------------------------------- 10 | COLUMN credential_name FORMAT A25 11 | COLUMN username FORMAT A20 12 | COLUMN windows_domain FORMAT A20 13 | 14 | SELECT credential_name, 15 | username, 16 | windows_domain 17 | FROM dba_credentials 18 | ORDER BY credential_name; -------------------------------------------------------------------------------- /12c/host_aces.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/12c/host_aces.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about host ACEs. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @host_aces 8 | -- Last Modified: 10/09/2014 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | 12 | COLUMN host FORMAT A20 13 | COLUMN principal FORMAT A30 14 | COLUMN privilege FORMAT A30 15 | COLUMN start_date FORMAT A11 16 | COLUMN end_date FORMAT A11 17 | 18 | SELECT host, 19 | lower_port, 20 | upper_port, 21 | ace_order, 22 | TO_CHAR(start_date, 'DD-MON-YYYY') AS start_date, 23 | TO_CHAR(end_date, 'DD-MON-YYYY') AS end_date, 24 | grant_type, 25 | inverted_principal, 26 | principal, 27 | principal_type, 28 | privilege 29 | FROM dba_host_aces 30 | ORDER BY host, ace_order; 31 | 32 | SET LINESIZE 80 -------------------------------------------------------------------------------- /12c/host_acls.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/12c/host_acls.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about host ACLs. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @host_acls 8 | -- Last Modified: 10/09/2014 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 150 11 | 12 | COLUMN acl FORMAT A50 13 | COLUMN host FORMAT A20 14 | COLUMN acl_owner FORMAT A10 15 | 16 | SELECT HOST, 17 | LOWER_PORT, 18 | UPPER_PORT, 19 | ACL, 20 | ACLID, 21 | ACL_OWNER 22 | FROM dba_host_acls 23 | ORDER BY host; 24 | 25 | SET LINESIZE 80 -------------------------------------------------------------------------------- /12c/login.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/12c/login.sql 4 | -- Author : Tim Hall 5 | -- Description : Resets the SQL*Plus prompt when a new connection is made. 6 | -- Includes PDB:CDB. 7 | -- Call Syntax : @login 8 | -- Last Modified: 21/04/2014 9 | -- ----------------------------------------------------------------------------------- 10 | SET FEEDBACK OFF 11 | SET TERMOUT OFF 12 | 13 | COLUMN X NEW_VALUE Y 14 | SELECT LOWER(USER || '@' || 15 | SYS_CONTEXT('userenv', 'con_name') || ':' || 16 | SYS_CONTEXT('userenv', 'instance_name')) X 17 | FROM dual; 18 | SET SQLPROMPT '&Y> ' 19 | 20 | ALTER SESSION SET NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS'; 21 | ALTER SESSION SET NLS_TIMESTAMP_FORMAT='DD-MON-YYYY HH24:MI:SS.FF'; 22 | 23 | SET TERMOUT ON 24 | SET FEEDBACK ON 25 | SET LINESIZE 100 26 | SET TAB OFF 27 | SET TRIM ON 28 | SET TRIMSPOOL ON -------------------------------------------------------------------------------- /12c/pdbs.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/12c/pdbs.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about all PDBs in the current CDB. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @pdbs 8 | -- Last Modified: 18/12/2013 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | COLUMN pdb_name FORMAT A20 12 | 13 | SELECT pdb_name, status 14 | FROM dba_pdbs 15 | ORDER BY pdb_name; 16 | 17 | SELECT name, open_mode 18 | FROM v$pdbs 19 | ORDER BY name; 20 | -------------------------------------------------------------------------------- /12c/plugin_violations.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/12c/plugin_violations.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about recent PDB plugin violations. 6 | -- Requirements : 7 | -- Call Syntax : @plugin_violations 8 | -- Last Modified: 09-JAN-2017 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET LINESIZE 200 12 | 13 | COLUMN time FORMAT A30 14 | COLUMN name FORMAT A30 15 | COLUMN cause FORMAT A30 16 | COLUMN message FORMAT A30 17 | 18 | SELECT time, name, cause, message 19 | FROM pdb_plug_in_violations 20 | WHERE time > TRUNC(SYSTIMESTAMP) 21 | ORDER BY time; -------------------------------------------------------------------------------- /12c/priv_captures.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/12c/priv_captures.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays privilege capture policies. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @priv_captures.sql 8 | -- Last Modified: 22-APR-2014 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | COLUMN name FORMAT A15 12 | COLUMN description FORMAT A30 13 | COLUMN roles FORMAT A20 14 | COLUMN context FORMAT A30 15 | SET LINESIZE 200 16 | 17 | SELECT name, 18 | description, 19 | type, 20 | enabled, 21 | roles, 22 | context 23 | FROM dba_priv_captures 24 | ORDER BY name; -------------------------------------------------------------------------------- /12c/redaction_policies.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/12c/redaction_policies.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays redaction policy information. 6 | -- Requirements : Access to the REDACTION_POLICIES view. 7 | -- Call Syntax : @redaction_policies 8 | -- Last Modified: 27-NOV-2014 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET LINESIZE 200 12 | 13 | COLUMN object_owner FORMAT A20 14 | COLUMN object_name FORMAT A30 15 | COLUMN policy_name FORMAT A30 16 | COLUMN expression FORMAT A30 17 | COLUMN policy_description FORMAT A20 18 | 19 | SELECT object_owner, 20 | object_name, 21 | policy_name, 22 | expression, 23 | enable, 24 | policy_description 25 | FROM redaction_policies 26 | ORDER BY 1, 2, 3; -------------------------------------------------------------------------------- /12c/redaction_value_defaults.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/12c/redaction_value_defaults.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about redaction defaults. 6 | -- Requirements : Access to the REDACTION_VALUES_FOR_TYPE_FULL view. 7 | -- Call Syntax : @redaction_value_defaults 8 | -- Last Modified: 27-NOV-2014 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET LINESIZE 250 12 | COLUMN char_value FORMAT A10 13 | COLUMN varchar_value FORMAT A10 14 | COLUMN nchar_value FORMAT A10 15 | COLUMN nvarchar_value FORMAT A10 16 | COLUMN timestamp_value FORMAT A27 17 | COLUMN timestamp_with_time_zone_value FORMAT A32 18 | COLUMN blob_value FORMAT A20 19 | COLUMN clob_value FORMAT A10 20 | COLUMN nclob_value FORMAT A10 21 | 22 | SELECT * 23 | FROM redaction_values_for_type_full; 24 | -------------------------------------------------------------------------------- /12c/services.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/services.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about database services. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @services 8 | -- Last Modified: 05/11/2004 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | COLUMN name FORMAT A30 12 | COLUMN network_name FORMAT A50 13 | COLUMN pdb FORMAT A20 14 | 15 | SELECT name, 16 | network_name, 17 | pdb 18 | FROM dba_services 19 | ORDER BY name; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | Download DBA scripts from 4 | 5 | https://oracle-base.com/dba/scripts 6 | 7 | -------------------------------------------------------------------------------- /constraints/disable_chk.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/constraints/disable_chk.sql 4 | -- Author : Tim Hall 5 | -- Description : Disables all check constraints for a specified table, or all tables. 6 | -- Call Syntax : @disable_chk (table-name or all) (schema-name) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'ALTER TABLE "' || a.table_name || '" DISABLE CONSTRAINT "' || a.constraint_name || '";' 16 | FROM all_constraints a 17 | WHERE a.constraint_type = 'C' 18 | AND a.owner = UPPER('&2'); 19 | AND a.table_name = DECODE(UPPER('&1'),'ALL',a.table_name,UPPER('&1')); 20 | 21 | SPOOL OFF 22 | 23 | -- Comment out following line to prevent immediate run 24 | @temp.sql 25 | 26 | SET PAGESIZE 14 27 | SET FEEDBACK ON 28 | SET VERIFY ON 29 | -------------------------------------------------------------------------------- /constraints/disable_fk.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/constraints/disable_fk.sql 4 | -- Author : Tim Hall 5 | -- Description : Disables all Foreign Keys belonging to the specified table, or all tables. 6 | -- Call Syntax : @disable_fk (table-name or all) (schema-name) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'ALTER TABLE "' || a.table_name || '" DISABLE CONSTRAINT "' || a.constraint_name || '";' 16 | FROM all_constraints a 17 | WHERE a.constraint_type = 'R' 18 | AND a.table_name = DECODE(Upper('&1'),'ALL',a.table_name,Upper('&1')) 19 | AND a.owner = Upper('&2'); 20 | 21 | SPOOL OFF 22 | 23 | -- Comment out following line to prevent immediate run 24 | @temp.sql 25 | 26 | SET PAGESIZE 14 27 | SET FEEDBACK ON 28 | SET VERIFY ON 29 | -------------------------------------------------------------------------------- /constraints/disable_pk.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/constraints/disable_pk.sql 4 | -- Author : Tim Hall 5 | -- Description : Disables the Primary Key for the specified table, or all tables. 6 | -- Call Syntax : @disable_pk (table-name or all) (schema-name) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'ALTER TABLE "' || a.table_name || '" DISABLE PRIMARY KEY;' 16 | FROM all_constraints a 17 | WHERE a.constraint_type = 'P' 18 | AND a.owner = Upper('&2') 19 | AND a.table_name = DECODE(Upper('&1'),'ALL',a.table_name,Upper('&1')); 20 | 21 | SPOOL OFF 22 | 23 | -- Comment out following line to prevent immediate run 24 | @temp.sql 25 | 26 | SET PAGESIZE 14 27 | SET FEEDBACK ON 28 | SET VERIFY ON 29 | -------------------------------------------------------------------------------- /constraints/enable_chk.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/constraints/enable_chk.sql 4 | -- Author : Tim Hall 5 | -- Description : Enables all check constraints for a specified table, or all tables. 6 | -- Call Syntax : @enable_chk (table-name or all) (schema-name) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'ALTER TABLE "' || a.table_name || '" ENABLE CONSTRAINT "' || a.constraint_name || '";' 16 | FROM all_constraints a 17 | WHERE a.constraint_type = 'C' 18 | AND a.owner = Upper('&2'); 19 | AND a.table_name = DECODE(Upper('&1'),'ALL',a.table_name,UPPER('&1')); 20 | 21 | SPOOL OFF 22 | 23 | -- Comment out following line to prevent immediate run 24 | @temp.sql 25 | 26 | SET PAGESIZE 14 27 | SET FEEDBACK ON 28 | SET VERIFY ON 29 | -------------------------------------------------------------------------------- /constraints/enable_fk.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/constraints/enable_fk.sql 4 | -- Author : Tim Hall 5 | -- Description : Enables all Foreign Keys belonging to the specified table, or all tables. 6 | -- Call Syntax : @enable_fk (table-name or all) (schema-name) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'ALTER TABLE "' || a.table_name || '" ENABLE CONSTRAINT "' || a.constraint_name || '";' 16 | FROM all_constraints a 17 | WHERE a.constraint_type = 'R' 18 | AND a.table_name = DECODE(Upper('&1'),'ALL',a.table_name,Upper('&1')) 19 | AND a.owner = Upper('&2'); 20 | 21 | SPOOL OFF 22 | 23 | -- Comment out following line to prevent immediate run 24 | @temp.sql 25 | 26 | SET PAGESIZE 14 27 | SET FEEDBACK ON 28 | SET VERIFY ON 29 | -------------------------------------------------------------------------------- /constraints/enable_pk.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/constraints/enable_pk.sql 4 | -- Author : Tim Hall 5 | -- Description : Enables the Primary Key for the specified table, or all tables. 6 | -- Call Syntax : @disable_pk (table-name or all) (schema-name) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'ALTER TABLE "' || a.table_name || '" ENABLE PRIMARY KEY;' 16 | FROM all_constraints a 17 | WHERE a.constraint_type = 'P' 18 | AND a.owner = Upper('&2') 19 | AND a.table_name = DECODE(Upper('&1'),'ALL',a.table_name,Upper('&1')); 20 | 21 | SPOOL OFF 22 | 23 | -- Comment out following line to prevent immediate run 24 | @temp.sql 25 | 26 | SET PAGESIZE 14 27 | SET FEEDBACK ON 28 | SET VERIFY ON 29 | -------------------------------------------------------------------------------- /miscellaneous/analyze_all.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/miscellaneous/analyze_all.sql 4 | -- Author : Tim Hall 5 | -- Description : Outdated script to analyze all tables for the specified schema. 6 | -- Comment : Use DBMS_UTILITY.ANALYZE_SCHEMA or DBMS_STATS.GATHER_SCHEMA_STATS if your server allows it. 7 | -- Call Syntax : @ananlyze_all (schema-name) 8 | -- Last Modified: 26/02/2002 9 | -- ----------------------------------------------------------------------------------- 10 | SET PAGESIZE 0 11 | SET FEEDBACK OFF 12 | SET VERIFY OFF 13 | 14 | SPOOL temp.sql 15 | 16 | SELECT 'ANALYZE TABLE "' || table_name || '" COMPUTE STATISTICS;' 17 | FROM all_tables 18 | WHERE owner = Upper('&1') 19 | ORDER BY 1; 20 | 21 | SPOOL OFF 22 | 23 | -- Comment out following line to prevent immediate run 24 | @temp.sql 25 | 26 | SET PAGESIZE 14 27 | SET FEEDBACK ON 28 | SET VERIFY ON 29 | -------------------------------------------------------------------------------- /miscellaneous/base64decode.sql: -------------------------------------------------------------------------------- 1 | 2 | CREATE OR REPLACE FUNCTION base64decode(p_clob CLOB) 3 | RETURN BLOB 4 | -- ----------------------------------------------------------------------------------- 5 | -- File Name : https://oracle-base.com/dba/miscellaneous/base64decode.sql 6 | -- Author : Tim Hall 7 | -- Description : Decodes a Base64 CLOB into a BLOB 8 | -- Last Modified: 09/11/2011 9 | -- ----------------------------------------------------------------------------------- 10 | IS 11 | l_blob BLOB; 12 | l_raw RAW(32767); 13 | l_amt NUMBER := 7700; 14 | l_offset NUMBER := 1; 15 | l_temp VARCHAR2(32767); 16 | BEGIN 17 | BEGIN 18 | DBMS_LOB.createtemporary (l_blob, FALSE, DBMS_LOB.CALL); 19 | LOOP 20 | DBMS_LOB.read(p_clob, l_amt, l_offset, l_temp); 21 | l_offset := l_offset + l_amt; 22 | l_raw := UTL_ENCODE.base64_decode(UTL_RAW.cast_to_raw(l_temp)); 23 | DBMS_LOB.append (l_blob, TO_BLOB(l_raw)); 24 | END LOOP; 25 | EXCEPTION 26 | WHEN NO_DATA_FOUND THEN 27 | NULL; 28 | END; 29 | RETURN l_blob; 30 | END; 31 | / -------------------------------------------------------------------------------- /miscellaneous/base64encode.sql: -------------------------------------------------------------------------------- 1 | 2 | CREATE OR REPLACE FUNCTION base64encode(p_blob IN BLOB) 3 | RETURN CLOB 4 | -- ----------------------------------------------------------------------------------- 5 | -- File Name : https://oracle-base.com/dba/miscellaneous/base64encode.sql 6 | -- Author : Tim Hall 7 | -- Description : Encodes a BLOB into a Base64 CLOB. 8 | -- Last Modified: 09/11/2011 9 | -- ----------------------------------------------------------------------------------- 10 | IS 11 | l_clob CLOB; 12 | l_step PLS_INTEGER := 12000; -- make sure you set a multiple of 3 not higher than 24573 13 | BEGIN 14 | FOR i IN 0 .. TRUNC((DBMS_LOB.getlength(p_blob) - 1 )/l_step) LOOP 15 | l_clob := l_clob || UTL_RAW.cast_to_varchar2(UTL_ENCODE.base64_encode(DBMS_LOB.substr(p_blob, l_step, i * l_step + 1))); 16 | END LOOP; 17 | RETURN l_clob; 18 | END; 19 | / -------------------------------------------------------------------------------- /miscellaneous/column_comments.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/miscellaneous/column_comments.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays comments associate with specific tables. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @column_comments (schema) (table-name) 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET VERIFY OFF 11 | SET PAGESIZE 100 12 | COLUMN column_name FORMAT A20 13 | COLUMN comments FORMAT A50 14 | 15 | SELECT column_name, 16 | comments 17 | FROM dba_col_comments 18 | WHERE owner = UPPER('&1') 19 | AND table_name = UPPER('&2') 20 | ORDER BY column_name; 21 | -------------------------------------------------------------------------------- /miscellaneous/comments.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/miscellaneous/comments.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays all comments for the specified table and its columns. 6 | -- Call Syntax : @comments (table-name) (schema-name) 7 | -- Last Modified: 15/07/2000 8 | -- ----------------------------------------------------------------------------------- 9 | PROMPT 10 | SET VERIFY OFF 11 | SET FEEDBACK OFF 12 | SET LINESIZE 255 13 | SET PAGESIZE 1000 14 | 15 | SELECT a.table_name "Table", 16 | a.table_type "Type", 17 | Substr(a.comments,1,200) "Comments" 18 | FROM all_tab_comments a 19 | WHERE a.table_name = Upper('&1') 20 | AND a.owner = Upper('&2'); 21 | 22 | SELECT a.column_name "Column", 23 | Substr(a.comments,1,200) "Comments" 24 | FROM all_col_comments a 25 | WHERE a.table_name = Upper('&1') 26 | AND a.owner = Upper('&2'); 27 | 28 | SET VERIFY ON 29 | SET FEEDBACK ON 30 | SET PAGESIZE 14 31 | PROMPT 32 | -------------------------------------------------------------------------------- /miscellaneous/compile_all.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/miscellaneous/compile_all.sql 4 | -- Author : Tim Hall 5 | -- Description : Compiles all invalid objects for specified schema, or all schema. 6 | -- Requirements : Requires all other "Compile_All" scripts. 7 | -- Call Syntax : @compile_all (schema-name or all) 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | @Compile_All_Specs &&1 11 | @Compile_All_Bodies &&1 12 | @Compile_All_Procs &&1 13 | @Compile_All_Funcs &&1 14 | @Compile_All_Views &&1 15 | -------------------------------------------------------------------------------- /miscellaneous/compile_all_bodies.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/miscellaneous/compile_all_bodies.sql 4 | -- Author : Tim Hall 5 | -- Description : Compiles all invalid package bodies for specified schema, or all schema. 6 | -- Call Syntax : @compile_all_bodies (schema-name or all) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'ALTER PACKAGE ' || a.owner || '.' || a.object_name || ' COMPILE BODY;' 16 | FROM all_objects a 17 | WHERE a.object_type = 'PACKAGE BODY' 18 | AND a.status = 'INVALID' 19 | AND a.owner = Decode(Upper('&&1'), 'ALL',a.owner, Upper('&&1')); 20 | 21 | SPOOL OFF 22 | 23 | -- Comment out following line to prevent immediate run 24 | @temp.sql 25 | 26 | SET PAGESIZE 14 27 | SET FEEDBACK ON 28 | SET VERIFY ON 29 | -------------------------------------------------------------------------------- /miscellaneous/compile_all_funcs.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/miscellaneous/compile_all_funcs.sql 4 | -- Author : Tim Hall 5 | -- Description : Compiles all invalid functions for specified schema, or all schema. 6 | -- Call Syntax : @compile_all_funcs (schema-name or all) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'ALTER FUNCTION ' || a.owner || '.' || a.object_name || ' COMPILE;' 16 | FROM all_objects a 17 | WHERE a.object_type = 'FUNCTION' 18 | AND a.status = 'INVALID' 19 | AND a.owner = Decode(Upper('&&1'), 'ALL',a.owner, Upper('&&1')); 20 | 21 | SPOOL OFF 22 | 23 | -- Comment out following line to prevent immediate run 24 | @temp.sql 25 | 26 | SET PAGESIZE 14 27 | SET FEEDBACK ON 28 | SET VERIFY ON 29 | -------------------------------------------------------------------------------- /miscellaneous/compile_all_procs.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/miscellaneous/compile_all_procs.sql 4 | -- Author : Tim Hall 5 | -- Description : Compiles all invalid procedures for specified schema, or all schema. 6 | -- Call Syntax : @compile_all_procs (schema-name or all) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'ALTER PROCEDURE ' || a.owner || '.' || a.object_name || ' COMPILE;' 16 | FROM all_objects a 17 | WHERE a.object_type = 'PROCEDURE' 18 | AND a.status = 'INVALID' 19 | AND a.owner = Decode(Upper('&&1'), 'ALL',a.owner, Upper('&&1')); 20 | 21 | SPOOL OFF 22 | 23 | -- Comment out following line to prevent immediate run 24 | @temp.sql 25 | 26 | SET PAGESIZE 14 27 | SET FEEDBACK ON 28 | SET VERIFY ON 29 | -------------------------------------------------------------------------------- /miscellaneous/compile_all_specs.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/miscellaneous/compile_all_specs.sql 4 | -- Author : Tim Hall 5 | -- Description : Compiles all invalid package specifications for specified schema, or all schema. 6 | -- Call Syntax : @compile_all_specs (schema-name or all) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'ALTER PACKAGE ' || a.owner || '.' || a.object_name || ' COMPILE;' 16 | FROM all_objects a 17 | WHERE a.object_type = 'PACKAGE' 18 | AND a.status = 'INVALID' 19 | AND a.owner = Decode(Upper('&&1'), 'ALL',a.owner, Upper('&&1')); 20 | 21 | SPOOL OFF 22 | 23 | -- Comment out following line to prevent immediate run 24 | @temp.sql 25 | 26 | SET PAGESIZE 14 27 | SET FEEDBACK ON 28 | SET VERIFY ON 29 | -------------------------------------------------------------------------------- /miscellaneous/compile_all_trigs.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/miscellaneous/compile_all_trigs.sql 4 | -- Author : Tim Hall 5 | -- Description : Compiles all invalid triggers for specified schema, or all schema. 6 | -- Call Syntax : @compile_all_trigs (schema-name or all) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'ALTER TRIGGER ' || a.owner || '.' || a.object_name || ' COMPILE;' 16 | FROM all_objects a 17 | WHERE a.object_type = 'TRIGGER' 18 | AND a.status = 'INVALID' 19 | AND a.owner = Decode(Upper('&&1'), 'ALL',a.owner, Upper('&&1')); 20 | 21 | SPOOL OFF 22 | 23 | -- Comment out following line to prevent immediate run 24 | @temp.sql 25 | 26 | SET PAGESIZE 14 27 | SET FEEDBACK ON 28 | SET VERIFY ON 29 | -------------------------------------------------------------------------------- /miscellaneous/compile_all_views.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/miscellaneous/compile_all_views.sql 4 | -- Author : Tim Hall 5 | -- Description : Compiles all invalid views for specified schema, or all schema. 6 | -- Call Syntax : @compile_all_views (schema-name or all) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'ALTER VIEW ' || a.owner || '.' || a.object_name || ' COMPILE;' 16 | FROM all_objects a 17 | WHERE a.object_type = 'VIEW' 18 | AND a.status = 'INVALID' 19 | AND a.owner = Decode(Upper('&&1'), 'ALL',a.owner, Upper('&&1')); 20 | 21 | SPOOL OFF 22 | 23 | -- Comment out following line to prevent immediate run 24 | @temp.sql 25 | 26 | SET PAGESIZE 14 27 | SET FEEDBACK ON 28 | SET VERIFY ON 29 | -------------------------------------------------------------------------------- /miscellaneous/dict_comments.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/miscellaneous/dict_comments.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays comments associate with specific tables. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @dict_comments (table-name or partial match) 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | PROMPT 11 | SET VERIFY OFF 12 | SET FEEDBACK OFF 13 | SET LINESIZE 255 14 | SET PAGESIZE 1000 15 | 16 | SELECT a.table_name "Table", 17 | Substr(a.comments,1,200) "Comments" 18 | FROM dictionary a 19 | WHERE a.table_name LIKE Upper('%&1%'); 20 | 21 | SET VERIFY ON 22 | SET FEEDBACK ON 23 | SET PAGESIZE 14 24 | PROMPT 25 | -------------------------------------------------------------------------------- /miscellaneous/find_object.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/miscellaneous/find_object.sql 4 | -- Author : Tim Hall 5 | -- Description : Lists all objects with a similar name to that specified. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @find_object (object-name) 8 | -- Last Modified: 26-JUL-2016 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET VERIFY OFF LINESIZE 200 12 | 13 | COLUMN object_name FORMAT A30 14 | COLUMN owner FORMAT A20 15 | 16 | SELECT object_name, owner, object_type, status 17 | FROM dba_objects 18 | WHERE LOWER(object_name) LIKE '%' || LOWER('&1') || '%' 19 | ORDER BY 1, 2, 3; 20 | -------------------------------------------------------------------------------- /miscellaneous/gen_health.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/miscellaneous/gen_health.sql 4 | -- Author : Tim Hall 5 | -- Description : Miscellaneous queries to check the general health of the system. 6 | -- Call Syntax : @gen_health 7 | -- Last Modified: 15/07/2000 8 | -- ----------------------------------------------------------------------------------- 9 | SELECT file_id, 10 | tablespace_name, 11 | file_name, 12 | status 13 | FROM sys.dba_data_files; 14 | 15 | SELECT file#, 16 | name, 17 | status, 18 | enabled 19 | FROM v$datafile; 20 | 21 | SELECT * 22 | FROM v$backup; 23 | 24 | SELECT * 25 | FROM v$recovery_status; 26 | 27 | SELECT * 28 | FROM v$recover_file; 29 | 30 | SELECT * 31 | FROM v$recovery_file_status; 32 | 33 | SELECT * 34 | FROM v$recovery_log; 35 | 36 | SELECT username, 37 | command, 38 | status, 39 | module 40 | FROM v$session; 41 | 42 | -------------------------------------------------------------------------------- /miscellaneous/get_pivot.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/miscellaneous/get_pivot.sql 4 | -- Author : Tim Hall 5 | -- Description : Creates a function to produce a virtual pivot table with the specific values. 6 | -- Requirements : CREATE TYPE, CREATE PROCEDURE 7 | -- Call Syntax : @get_pivot.sql 8 | -- Last Modified: 13/08/2003 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | CREATE OR REPLACE TYPE t_pivot AS TABLE OF NUMBER; 12 | / 13 | 14 | CREATE OR REPLACE FUNCTION get_pivot(p_max IN NUMBER, 15 | p_step IN NUMBER DEFAULT 1) 16 | RETURN t_pivot AS 17 | l_pivot t_pivot := t_pivot(); 18 | BEGIN 19 | FOR i IN 0 .. TRUNC(p_max/p_step) LOOP 20 | l_pivot.extend; 21 | l_pivot(l_pivot.last) := 1 + (i * p_step); 22 | END LOOP; 23 | RETURN l_pivot; 24 | END; 25 | / 26 | SHOW ERRORS 27 | 28 | SELECT column_value 29 | FROM TABLE(get_pivot(17,2)); 30 | 31 | -------------------------------------------------------------------------------- /miscellaneous/login.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/miscellaneous/login.sql 4 | -- Author : Tim Hall 5 | -- Description : Resets the SQL*Plus prompt when a new connection is made. 6 | -- Call Syntax : @login 7 | -- Last Modified: 04/03/2004 8 | -- ----------------------------------------------------------------------------------- 9 | SET FEEDBACK OFF 10 | SET TERMOUT OFF 11 | 12 | COLUMN X NEW_VALUE Y 13 | SELECT LOWER(USER || '@' || SYS_CONTEXT('userenv', 'instance_name')) X FROM dual; 14 | SET SQLPROMPT '&Y> ' 15 | 16 | ALTER SESSION SET NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS'; 17 | ALTER SESSION SET NLS_TIMESTAMP_FORMAT='DD-MON-YYYY HH24:MI:SS.FF'; 18 | 19 | SET TERMOUT ON 20 | SET FEEDBACK ON 21 | SET LINESIZE 100 22 | SET TAB OFF 23 | SET TRIM ON 24 | SET TRIMSPOOL ON 25 | -------------------------------------------------------------------------------- /miscellaneous/rebuild_index.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/miscellaneous/rebuild_index.sql 4 | -- Author : Tim Hall 5 | -- Description : Rebuilds the specified index, or all indexes. 6 | -- Call Syntax : @rebuild_index (index-name or all) (schema-name) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'ALTER INDEX ' || a.index_name || ' REBUILD;' 16 | FROM all_indexes a 17 | WHERE index_name = DECODE(Upper('&1'),'ALL',a.index_name,Upper('&1')) 18 | AND table_owner = Upper('&2') 19 | ORDER BY 1 20 | / 21 | 22 | SPOOL OFF 23 | 24 | -- Comment out following line to prevent immediate run 25 | @temp.sql 26 | 27 | SET PAGESIZE 14 28 | SET FEEDBACK ON 29 | SET VERIFY ON 30 | -------------------------------------------------------------------------------- /miscellaneous/table_comments.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/miscellaneous/table_comments.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays comments associate with specific tables. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @table_comments (schema or all) (table-name or partial match) 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET VERIFY OFF 11 | COLUMN table_name FORMAT A30 12 | COLUMN comments FORMAT A40 13 | 14 | SELECT table_name, 15 | comments 16 | FROM dba_tab_comments 17 | WHERE owner = DECODE(UPPER('&1'), 'ALL', owner, UPPER('&1')) 18 | AND table_name LIKE UPPER('%&2%') 19 | ORDER BY table_name; 20 | -------------------------------------------------------------------------------- /monitoring/access.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/access.sql 4 | -- Author : Tim Hall 5 | -- Description : Lists all objects being accessed in the schema. 6 | -- Call Syntax : @access (schema-name or all) (object-name or all) 7 | -- Requirements : Access to the v$views. 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 255 11 | SET VERIFY OFF 12 | 13 | COLUMN object FORMAT A30 14 | 15 | SELECT a.object, 16 | a.type, 17 | a.sid, 18 | b.serial#, 19 | b.username, 20 | b.osuser, 21 | b.program 22 | FROM v$access a, 23 | v$session b 24 | WHERE a.sid = b.sid 25 | AND a.owner = DECODE(UPPER('&1'), 'ALL', a.object, UPPER('&1')) 26 | AND a.object = DECODE(UPPER('&2'), 'ALL', a.object, UPPER('&2')) 27 | ORDER BY a.object; 28 | -------------------------------------------------------------------------------- /monitoring/call_stack.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/call_stack.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the current call stack. 6 | -- Requirements : Access to DBMS_UTILITY. 7 | -- Call Syntax : @call_stack 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET SERVEROUTPUT ON 11 | DECLARE 12 | v_stack VARCHAR2(2000); 13 | BEGIN 14 | v_stack := Dbms_Utility.Format_Call_Stack; 15 | Dbms_Output.Put_Line(v_stack); 16 | END; 17 | / 18 | -------------------------------------------------------------------------------- /monitoring/code_dep.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/code_dep.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays all dependencies of specified object. 6 | -- Call Syntax : @code_dep (schema-name or all) (object-name) 7 | -- Last Modified: 15/07/2000 8 | -- ----------------------------------------------------------------------------------- 9 | SET VERIFY OFF 10 | SET LINESIZE 255 11 | SET PAGESIZE 1000 12 | BREAK ON referenced_type SKIP 1 13 | 14 | COLUMN referenced_type FORMAT A20 15 | COLUMN referenced_owner FORMAT A20 16 | COLUMN referenced_name FORMAT A40 17 | COLUMN referenced_link_name FORMAT A20 18 | 19 | SELECT a.referenced_type, 20 | a.referenced_owner, 21 | a.referenced_name, 22 | a.referenced_link_name 23 | FROM all_dependencies a 24 | WHERE a.owner = DECODE(UPPER('&1'), 'ALL', a.referenced_owner, UPPER('&1')) 25 | AND a.name = UPPER('&2') 26 | ORDER BY 1,2,3; 27 | 28 | SET VERIFY ON 29 | SET PAGESIZE 22 -------------------------------------------------------------------------------- /monitoring/code_dep_on.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/code_dep_on.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays all objects dependant on the specified object. 6 | -- Call Syntax : @code_dep_on (schema-name or all) (object-name) 7 | -- Last Modified: 15/07/2000 8 | -- ----------------------------------------------------------------------------------- 9 | SET VERIFY OFF 10 | SET LINESIZE 255 11 | SET PAGESIZE 1000 12 | BREAK ON type SKIP 1 13 | 14 | COLUMN owner FORMAT A20 15 | 16 | SELECT a.type, 17 | a.owner, 18 | a.name 19 | FROM all_dependencies a 20 | WHERE a.referenced_owner = DECODE(UPPER('&1'), 'ALL', a.referenced_owner, UPPER('&1')) 21 | AND a.referenced_name = UPPER('&2') 22 | ORDER BY 1,2,3; 23 | 24 | SET PAGESIZE 22 25 | SET VERIFY ON -------------------------------------------------------------------------------- /monitoring/column_defaults.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/column_defaults.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the default values where present for the specified table. 6 | -- Call Syntax : @column_defaults (table-name) 7 | -- Last Modified: 15/07/2000 8 | -- ----------------------------------------------------------------------------------- 9 | SET LINESIZE 100 10 | SET VERIFY OFF 11 | 12 | SELECT a.column_name "Column", 13 | a.data_default "Default" 14 | FROM all_tab_columns a 15 | WHERE a.table_name = Upper('&1') 16 | AND a.data_default IS NOT NULL 17 | / -------------------------------------------------------------------------------- /monitoring/controlfiles.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/controlfiles.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about controlfiles. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @controlfiles 8 | -- Last Modified: 21/12/2004 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET LINESIZE 100 12 | COLUMN name FORMAT A80 13 | 14 | SELECT name, 15 | status 16 | FROM v$controlfile 17 | ORDER BY name; 18 | 19 | SET LINESIZE 80 -------------------------------------------------------------------------------- /monitoring/datafiles.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/datafiles.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about datafiles. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @datafiles 8 | -- Last Modified: 17-AUG-2005 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET LINESIZE 200 12 | COLUMN file_name FORMAT A70 13 | 14 | SELECT file_id, 15 | file_name, 16 | ROUND(bytes/1024/1024/1024) AS size_gb, 17 | ROUND(maxbytes/1024/1024/1024) AS max_size_gb, 18 | autoextensible, 19 | increment_by, 20 | status 21 | FROM dba_data_files 22 | ORDER BY file_name; 23 | -------------------------------------------------------------------------------- /monitoring/db_links.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/db_links.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information on all database links. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @db_links 8 | -- Last Modified: 11/05/2007 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 150 11 | 12 | COLUMN owner FORMAT A30 13 | COLUMN db_link FORMAT A30 14 | COLUMN username FORMAT A30 15 | COLUMN host FORMAT A30 16 | 17 | SELECT owner, 18 | db_link, 19 | username, 20 | host 21 | FROM dba_db_links 22 | ORDER BY owner, db_link; 23 | -------------------------------------------------------------------------------- /monitoring/db_links_open.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/db_links_open.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information on all open database links. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @db_links_open 8 | -- Last Modified: 11/05/2007 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | 12 | COLUMN db_link FORMAT A30 13 | 14 | SELECT db_link, 15 | owner_id, 16 | logged_on, 17 | heterogeneous, 18 | protocol, 19 | open_cursors, 20 | in_transaction, 21 | update_sent, 22 | commit_point_strength 23 | FROM v$dblink 24 | ORDER BY db_link; 25 | 26 | SET LINESIZE 80 27 | -------------------------------------------------------------------------------- /monitoring/db_properties.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/db_properties.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays all database property values. 6 | -- Call Syntax : @db_properties 7 | -- Last Modified: 15/09/2006 8 | -- ----------------------------------------------------------------------------------- 9 | COLUMN property_value FORMAT A50 10 | 11 | SELECT property_name, 12 | property_value 13 | FROM database_properties 14 | ORDER BY property_name; 15 | -------------------------------------------------------------------------------- /monitoring/directories.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/directories.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about all directories. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @directories 8 | -- Last Modified: 04/10/2006 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 150 11 | 12 | COLUMN owner FORMAT A20 13 | COLUMN directory_name FORMAT A25 14 | COLUMN directory_path FORMAT A80 15 | 16 | SELECT * 17 | FROM dba_directories 18 | ORDER BY owner, directory_name; 19 | -------------------------------------------------------------------------------- /monitoring/directory_permissions.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/directory_permissions.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays permission information about all directories. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @directory_permissions (directory_name) 8 | -- Last Modified: 09/02/2016 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | 12 | COLUMN grantee FORMAT A20 13 | COLUMN owner FORMAT A10 14 | COLUMN grantor FORMAT A20 15 | COLUMN privilege FORMAT A20 16 | 17 | COLUMN 18 | SELECT * 19 | FROM dba_tab_privs 20 | WHERE table_name = UPPER('&1'); 21 | -------------------------------------------------------------------------------- /monitoring/dispatchers.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/dispatchers.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays dispatcher statistics. 6 | -- Requirements : Access to the v$ views. 7 | -- Call Syntax : @dispatchers 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 500 11 | SET PAGESIZE 1000 12 | SET VERIFY OFF 13 | 14 | SELECT a.name "Name", 15 | a.status "Status", 16 | a.accept "Accept", 17 | a.messages "Total Mesgs", 18 | a.bytes "Total Bytes", 19 | a.owned "Circs Owned", 20 | a.idle "Total Idle Time", 21 | a.busy "Total Busy Time", 22 | Round(a.busy/(a.busy + a.idle),2) "Load" 23 | FROM v$dispatcher a 24 | ORDER BY 1; 25 | 26 | SET PAGESIZE 14 27 | SET VERIFY ON -------------------------------------------------------------------------------- /monitoring/error_stack.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/error_stack.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays contents of the error stack. 6 | -- Call Syntax : @error_stack 7 | -- Last Modified: 15/07/2000 8 | -- ----------------------------------------------------------------------------------- 9 | SET SERVEROUTPUT ON 10 | DECLARE 11 | v_stack VARCHAR2(2000); 12 | BEGIN 13 | v_stack := Dbms_Utility.Format_Error_Stack; 14 | Dbms_Output.Put_Line(v_stack); 15 | END; 16 | / 17 | -------------------------------------------------------------------------------- /monitoring/errors.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/errors.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the source line and the associated error after compilation failure. 6 | -- Comments : Essentially the same as SHOW ERRORS. 7 | -- Call Syntax : @errors (source-name) 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SELECT To_Char(a.line) || ' - ' || a.text error 11 | FROM user_source a, 12 | user_errors b 13 | WHERE a.name = Upper('&&1') 14 | AND a.name = b.name 15 | AND a.type = b.type 16 | AND a.line = b.line 17 | ORDER BY a.name, a.line; -------------------------------------------------------------------------------- /monitoring/file_io.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/file_io.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the amount of IO for each datafile. 6 | -- Requirements : Access to the v$ views. 7 | -- Call Syntax : @file_io 8 | -- Last Modified: 15-JUL-2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET PAGESIZE 1000 11 | 12 | SELECT Substr(d.name,1,50) "File Name", 13 | f.phyblkrd "Blocks Read", 14 | f.phyblkwrt "Blocks Writen", 15 | f.phyblkrd + f.phyblkwrt "Total I/O" 16 | FROM v$filestat f, 17 | v$datafile d 18 | WHERE d.file# = f.file# 19 | ORDER BY f.phyblkrd + f.phyblkwrt DESC; 20 | 21 | SET PAGESIZE 18 -------------------------------------------------------------------------------- /monitoring/health.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/health.sql 4 | -- Author : Tim Hall 5 | -- Description : Lots of information about the database so you can asses the general health of the system. 6 | -- Requirements : Access to the V$ & DBA views and several other monitoring scripts. 7 | -- Call Syntax : @health (username/password@service) 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SPOOL Health_Checks.txt 11 | 12 | conn &1 13 | @db_info 14 | @sessions 15 | @ts_full 16 | @max_extents 17 | 18 | SPOOL OFF -------------------------------------------------------------------------------- /monitoring/identify_trace_file.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/identify_trace_file.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the name of the trace file associated with the current session. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @identify_trace_file 8 | -- Last Modified: 17-AUG-2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 100 11 | COLUMN trace_file FORMAT A60 12 | 13 | SELECT s.sid, 14 | s.serial#, 15 | pa.value || '/' || LOWER(SYS_CONTEXT('userenv','instance_name')) || 16 | '_ora_' || p.spid || '.trc' AS trace_file 17 | FROM v$session s, 18 | v$process p, 19 | v$parameter pa 20 | WHERE pa.name = 'user_dump_dest' 21 | AND s.paddr = p.addr 22 | AND s.audsid = SYS_CONTEXT('USERENV', 'SESSIONID'); -------------------------------------------------------------------------------- /monitoring/index_monitoring_status.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/index_monitoring_status.sql 4 | -- Author : Tim Hall 5 | -- Description : Shows the monitoring status for the specified table indexes. 6 | -- Call Syntax : @index_monitoring_status (table-name) (index-name or all) 7 | -- Last Modified: 04/02/2005 8 | -- ----------------------------------------------------------------------------------- 9 | SET VERIFY OFF 10 | 11 | SELECT table_name, 12 | index_name, 13 | monitoring 14 | FROM v$object_usage 15 | WHERE table_name = UPPER('&1') 16 | AND index_name = DECODE(UPPER('&2'), 'ALL', index_name, UPPER('&2')); 17 | -------------------------------------------------------------------------------- /monitoring/index_partitions.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/index_partitions.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays partition information for the specified index, or all indexes. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @index_patitions (index_name or all) (schema-name) 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 500 11 | SET PAGESIZE 1000 12 | SET FEEDBACK OFF 13 | SET VERIFY OFF 14 | 15 | SELECT a.index_name, 16 | a.partition_name, 17 | a.tablespace_name, 18 | a.initial_extent, 19 | a.next_extent, 20 | a.pct_increase, 21 | a.num_rows 22 | FROM dba_ind_partitions a 23 | WHERE a.index_name = Decode(Upper('&&1'),'ALL',a.index_name,Upper('&&1')) 24 | AND a.index_owner = Upper('&&2') 25 | ORDER BY a.index_name, a.partition_name 26 | / 27 | 28 | PROMPT 29 | SET PAGESIZE 14 30 | SET FEEDBACK ON 31 | -------------------------------------------------------------------------------- /monitoring/index_usage.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/index_usage.sql 4 | -- Author : Tim Hall 5 | -- Description : Shows the usage for the specified table indexes. 6 | -- Call Syntax : @index_usage (table-name) (index-name or all) 7 | -- Last Modified: 04/02/2005 8 | -- ----------------------------------------------------------------------------------- 9 | SET VERIFY OFF 10 | SET LINESIZE 200 11 | 12 | SELECT table_name, 13 | index_name, 14 | used, 15 | start_monitoring, 16 | end_monitoring 17 | FROM v$object_usage 18 | WHERE table_name = UPPER('&1') 19 | AND index_name = DECODE(UPPER('&2'), 'ALL', index_name, UPPER('&2')); 20 | -------------------------------------------------------------------------------- /monitoring/invalid_objects.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/invalid_objects.sql 4 | -- Author : Tim Hall 5 | -- Description : Lists all invalid objects in the database. 6 | -- Call Syntax : @invalid_objects 7 | -- Requirements : Access to the DBA views. 8 | -- Last Modified: 18/12/2005 9 | -- ----------------------------------------------------------------------------------- 10 | COLUMN owner FORMAT A30 11 | COLUMN object_name FORMAT A30 12 | 13 | SELECT owner, 14 | object_type, 15 | object_name, 16 | status 17 | FROM dba_objects 18 | WHERE status = 'INVALID' 19 | ORDER BY owner, object_type, object_name; 20 | -------------------------------------------------------------------------------- /monitoring/jobs_running.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/jobs_running.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about all jobs currently running. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @jobs_running 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 500 11 | SET PAGESIZE 1000 12 | SET VERIFY OFF 13 | 14 | SELECT a.job "Job", 15 | a.sid, 16 | a.failures "Failures", 17 | Substr(To_Char(a.last_date,'DD-Mon-YYYY HH24:MI:SS'),1,20) "Last Date", 18 | Substr(To_Char(a.this_date,'DD-Mon-YYYY HH24:MI:SS'),1,20) "This Date" 19 | FROM dba_jobs_running a; 20 | 21 | SET PAGESIZE 14 22 | SET VERIFY ON -------------------------------------------------------------------------------- /monitoring/large_segments.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/large_segments.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays size of large segments. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @large_segments (rows) 8 | -- Last Modified: 12/09/2017 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 500 VERIFY OFF 11 | COLUMN owner FORMAT A30 12 | COLUMN segment_name FORMAT A30 13 | COLUMN tablespace_name FORMAT A30 14 | COLUMN size_mb FORMAT 99999999.00 15 | 16 | SELECT * 17 | FROM (SELECT owner, 18 | segment_name, 19 | segment_type, 20 | tablespace_name, 21 | ROUND(bytes/1024/1024,2) size_mb 22 | FROM dba_segments 23 | ORDER BY 5 DESC) 24 | WHERE ROWNUM <= &1; 25 | 26 | SET VERIFY ON -------------------------------------------------------------------------------- /monitoring/latch_hit_ratios.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/latch_hit_ratios.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays current latch hit ratios. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @latch_hit_ratios 8 | -- Last Modified: 15-JUL-2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | 12 | COLUMN latch_hit_ratio FORMAT 990.00 13 | 14 | SELECT l.name, 15 | l.gets, 16 | l.misses, 17 | ((1 - (l.misses / l.gets)) * 100) AS latch_hit_ratio 18 | FROM v$latch l 19 | WHERE l.gets != 0 20 | UNION 21 | SELECT l.name, 22 | l.gets, 23 | l.misses, 24 | 100 AS latch_hit_ratio 25 | FROM v$latch l 26 | WHERE l.gets = 0 27 | ORDER BY 4 DESC; 28 | -------------------------------------------------------------------------------- /monitoring/latch_holders.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/latch_holders.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about all current latch holders. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @latch_holders 8 | -- Last Modified: 15-JUL-2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | 12 | SELECT l.name "Latch Name", 13 | lh.pid "PID", 14 | lh.sid "SID", 15 | l.gets "Gets (Wait)", 16 | l.misses "Misses (Wait)", 17 | l.sleeps "Sleeps (Wait)", 18 | l.immediate_gets "Gets (No Wait)", 19 | l.immediate_misses "Misses (Wait)" 20 | FROM v$latch l, 21 | v$latchholder lh 22 | WHERE l.addr = lh.laddr 23 | ORDER BY l.name; 24 | -------------------------------------------------------------------------------- /monitoring/latches.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/latches.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about all current latches. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @latches 8 | -- Last Modified: 15-JUL-2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | 12 | SELECT l.latch#, 13 | l.name, 14 | l.gets, 15 | l.misses, 16 | l.sleeps, 17 | l.immediate_gets, 18 | l.immediate_misses, 19 | l.spin_gets 20 | FROM v$latch l 21 | ORDER BY l.name; 22 | -------------------------------------------------------------------------------- /monitoring/library_cache.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/library_cache.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays library cache statistics. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @library_cache 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 500 11 | SET PAGESIZE 1000 12 | SET VERIFY OFF 13 | 14 | SELECT a.namespace "Name Space", 15 | a.gets "Get Requests", 16 | a.gethits "Get Hits", 17 | Round(a.gethitratio,2) "Get Ratio", 18 | a.pins "Pin Requests", 19 | a.pinhits "Pin Hits", 20 | Round(a.pinhitratio,2) "Pin Ratio", 21 | a.reloads "Reloads", 22 | a.invalidations "Invalidations" 23 | FROM v$librarycache a 24 | ORDER BY 1; 25 | 26 | SET PAGESIZE 14 27 | SET VERIFY ON -------------------------------------------------------------------------------- /monitoring/license.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/license.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays session usage for licensing purposes. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @license 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SELECT * 11 | FROM v$license; 12 | -------------------------------------------------------------------------------- /monitoring/locked_objects_internal.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/locked_objects_internal.sql 4 | -- Author : Tim Hall 5 | -- Description : Lists all locks on the specific object. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @locked_objects_internal (object-name) 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 1000 VERIFY OFF 11 | 12 | COLUMN lock_type FORMAT A20 13 | COLUMN mode_held FORMAT A10 14 | COLUMN mode_requested FORMAT A10 15 | COLUMN lock_id1 FORMAT A50 16 | COLUMN lock_id2 FORMAT A30 17 | 18 | SELECT li.session_id AS sid, 19 | s.serial#, 20 | li.lock_type, 21 | li.mode_held, 22 | li.mode_requested, 23 | li.lock_id1, 24 | li.lock_id2 25 | FROM dba_lock_internal li 26 | JOIN v$session s ON li.session_id = s.sid 27 | WHERE UPPER(lock_id1) LIKE '%&1%'; 28 | 29 | SET VERIFY ON -------------------------------------------------------------------------------- /monitoring/logfiles.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/logfiles.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about redo log files. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @logfiles 8 | -- Last Modified: 21/12/2004 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET LINESIZE 200 12 | COLUMN member FORMAT A50 13 | COLUMN first_change# FORMAT 99999999999999999999 14 | COLUMN next_change# FORMAT 99999999999999999999 15 | 16 | SELECT l.thread#, 17 | lf.group#, 18 | lf.member, 19 | TRUNC(l.bytes/1024/1024) AS size_mb, 20 | l.status, 21 | l.archived, 22 | lf.type, 23 | lf.is_recovery_dest_file AS rdf, 24 | l.sequence#, 25 | l.first_change#, 26 | l.next_change# 27 | FROM v$logfile lf 28 | JOIN v$log l ON l.group# = lf.group# 29 | ORDER BY l.thread#,lf.group#, lf.member; 30 | 31 | SET LINESIZE 80 32 | -------------------------------------------------------------------------------- /monitoring/longops.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/longops.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information on all long operations. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @longops 8 | -- Last Modified: 03/07/2003 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | COLUMN sid FORMAT 999 12 | COLUMN serial# FORMAT 9999999 13 | COLUMN machine FORMAT A30 14 | COLUMN progress_pct FORMAT 99999999.00 15 | COLUMN elapsed FORMAT A10 16 | COLUMN remaining FORMAT A10 17 | 18 | SELECT s.sid, 19 | s.serial#, 20 | s.machine, 21 | ROUND(sl.elapsed_seconds/60) || ':' || MOD(sl.elapsed_seconds,60) elapsed, 22 | ROUND(sl.time_remaining/60) || ':' || MOD(sl.time_remaining,60) remaining, 23 | ROUND(sl.sofar/sl.totalwork*100, 2) progress_pct 24 | FROM v$session s, 25 | v$session_longops sl 26 | WHERE s.sid = sl.sid 27 | AND s.serial# = sl.serial#; 28 | -------------------------------------------------------------------------------- /monitoring/lru_latch_ratio.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/lru_latch_ratio.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays current LRU latch ratios. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @lru_latch_hit_ratio 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 500 11 | SET PAGESIZE 1000 12 | COLUMN "Ratio %" FORMAT 990.00 13 | 14 | PROMPT 15 | PROMPT Values greater than 3% indicate contention. 16 | 17 | SELECT a.child#, 18 | (a.SLEEPS / a.GETS) * 100 "Ratio %" 19 | FROM v$latch_children a 20 | WHERE a.name = 'cache buffers lru chain' 21 | ORDER BY 1; 22 | 23 | 24 | SET PAGESIZE 14 25 | -------------------------------------------------------------------------------- /monitoring/monitor.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/monitor.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays SQL statements for the current database sessions. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @monitor 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET VERIFY OFF 11 | SET LINESIZE 255 12 | COL SID FORMAT 999 13 | COL STATUS FORMAT A8 14 | COL PROCESS FORMAT A10 15 | COL SCHEMANAME FORMAT A16 16 | COL OSUSER FORMAT A16 17 | COL SQL_TEXT FORMAT A120 HEADING 'SQL QUERY' 18 | COL PROGRAM FORMAT A30 19 | 20 | SELECT s.sid, 21 | s.status, 22 | s.process, 23 | s.schemaname, 24 | s.osuser, 25 | a.sql_text, 26 | p.program 27 | FROM v$session s, 28 | v$sqlarea a, 29 | v$process p 30 | WHERE s.SQL_HASH_VALUE = a.HASH_VALUE 31 | AND s.SQL_ADDRESS = a.ADDRESS 32 | AND s.PADDR = p.ADDR 33 | / 34 | 35 | SET VERIFY ON 36 | SET LINESIZE 255 -------------------------------------------------------------------------------- /monitoring/monitor_memory.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/monitor_memory.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays memory allocations for the current database sessions. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @monitor_memory 8 | -- Last Modified: 15-JUL-2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | 12 | COLUMN username FORMAT A20 13 | COLUMN module FORMAT A20 14 | 15 | SELECT NVL(a.username,'(oracle)') AS username, 16 | a.module, 17 | a.program, 18 | Trunc(b.value/1024) AS memory_kb 19 | FROM v$session a, 20 | v$sesstat b, 21 | v$statname c 22 | WHERE a.sid = b.sid 23 | AND b.statistic# = c.statistic# 24 | AND c.name = 'session pga memory' 25 | AND a.program IS NOT NULL 26 | ORDER BY b.value DESC; -------------------------------------------------------------------------------- /monitoring/monitoring_status.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/monitoring_status.sql 4 | -- Author : Tim Hall 5 | -- Description : Shows the monitoring status for the specified tables. 6 | -- Call Syntax : @monitoring_status (schema) (table-name or all) 7 | -- Last Modified: 21/03/2003 8 | -- ----------------------------------------------------------------------------------- 9 | SET VERIFY OFF 10 | 11 | SELECT table_name, monitoring 12 | FROM dba_tables 13 | WHERE owner = UPPER('&1') 14 | AND table_name = DECODE(UPPER('&2'), 'ALL', table_name, UPPER('&2')); 15 | -------------------------------------------------------------------------------- /monitoring/nls_params.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/nls_params.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays National Language Suppport (NLS) information. 6 | -- Requirements : 7 | -- Call Syntax : @nls_params 8 | -- Last Modified: 21-FEB-2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 100 11 | COLUMN parameter FORMAT A45 12 | COLUMN value FORMAT A45 13 | 14 | PROMPT *** Database parameters *** 15 | SELECT * FROM nls_database_parameters ORDER BY 1; 16 | 17 | PROMPT *** Instance parameters *** 18 | SELECT * FROM nls_instance_parameters ORDER BY 1; 19 | 20 | PROMPT *** Session parameters *** 21 | SELECT * FROM nls_session_parameters ORDER BY 1; -------------------------------------------------------------------------------- /monitoring/obj_lock.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/obj_lock.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays a list of locked objects. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @obj_lock 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SELECT a.type, 11 | Substr(a.owner,1,30) owner, 12 | a.sid, 13 | Substr(a.object,1,30) object 14 | FROM v$access a 15 | WHERE a.owner NOT IN ('SYS','PUBLIC') 16 | ORDER BY 1,2,3,4 17 | / 18 | -------------------------------------------------------------------------------- /monitoring/object_privs.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/object_privs.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays object privileges on a specified object. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @object_privs (owner) (object-name) 8 | -- Last Modified: 27/07/2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 VERIFY OFF 11 | 12 | SELECT owner, 13 | table_name AS object_name, 14 | grantor, 15 | grantee, 16 | privilege, 17 | grantable, 18 | hierarchy 19 | FROM dba_tab_privs 20 | WHERE owner = UPPER('&1') 21 | AND table_name = UPPER('&2') 22 | ORDER BY 1,2,3,4; 23 | 24 | SET VERIFY ON -------------------------------------------------------------------------------- /monitoring/object_status.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/object_status.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays a list of objects and their status for the specific schema. 6 | -- Requirements : Access to the ALL views. 7 | -- Call Syntax : @object_status (schema-name) 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET SERVEROUTPUT ON 11 | SET PAGESIZE 1000 12 | SET LINESIZE 255 13 | SET FEEDBACK OFF 14 | SET VERIFY OFF 15 | 16 | SELECT Substr(object_name,1,30) object_name, 17 | object_type, 18 | status 19 | FROM all_objects 20 | WHERE owner = Upper('&&1'); 21 | 22 | PROMPT 23 | SET FEEDBACK ON 24 | SET PAGESIZE 18 25 | -------------------------------------------------------------------------------- /monitoring/open_cursors.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/open_cursors.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays a list of all cursors currently open. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @open_cursors 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SELECT a.user_name, 11 | a.sid, 12 | a.sql_text 13 | FROM v$open_cursor a 14 | ORDER BY 1,2 15 | / 16 | -------------------------------------------------------------------------------- /monitoring/open_cursors_by_sid.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/open_cursors_by_sid.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the SQL statement held for a specific SID. 6 | -- Comments : The SID can be found by running session.sql or top_session.sql. 7 | -- Requirements : Access to the V$ views. 8 | -- Call Syntax : @open_cursors_by_sid (sid) 9 | -- Last Modified: 15/07/2000 10 | -- ----------------------------------------------------------------------------------- 11 | SET LINESIZE 500 12 | SET PAGESIZE 1000 13 | SET VERIFY OFF 14 | 15 | SELECT oc.sql_text, cursor_type 16 | FROM v$open_cursor oc 17 | WHERE oc.sid = &1 18 | ORDER BY cursor_type; 19 | 20 | PROMPT 21 | SET PAGESIZE 14 -------------------------------------------------------------------------------- /monitoring/open_cursors_full_by_sid.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/open_cursors_full_by_sid.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the SQL statement held for a specific SID. 6 | -- Comments : The SID can be found by running session.sql or top_session.sql. 7 | -- Requirements : Access to the V$ views. 8 | -- Call Syntax : @open_cursors_full_by_sid (sid) 9 | -- Last Modified: 15/07/2000 10 | -- ----------------------------------------------------------------------------------- 11 | SET LINESIZE 500 12 | SET PAGESIZE 1000 13 | SET VERIFY OFF 14 | 15 | SELECT st.sql_text 16 | FROM v$sqltext st, 17 | v$open_cursor oc 18 | WHERE st.address = oc.address 19 | AND st.hash_value = oc.hash_value 20 | AND oc.sid = &1 21 | ORDER BY st.address, st.piece; 22 | 23 | PROMPT 24 | SET PAGESIZE 14 25 | -------------------------------------------------------------------------------- /monitoring/options.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/options.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about all database options. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @options 8 | -- Last Modified: 12/04/2013 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | COLUMN value FORMAT A20 12 | 13 | SELECT * 14 | FROM v$option 15 | ORDER BY parameter; 16 | -------------------------------------------------------------------------------- /monitoring/param_valid_values.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/param_valid_values.sql 4 | -- Author : Tim Hall 5 | -- Description : Lists all valid values for the specified parameter. 6 | -- Call Syntax : @param_valid_values (parameter-name) 7 | -- Requirements : Access to the v$views. 8 | -- Last Modified: 14/05/2013 9 | -- ----------------------------------------------------------------------------------- 10 | SET VERIFY OFF 11 | 12 | COLUMN value FORMAT A50 13 | COLUMN isdefault FORMAT A10 14 | 15 | SELECT value, 16 | isdefault 17 | FROM v$parameter_valid_values 18 | WHERE name = '&1'; 19 | -------------------------------------------------------------------------------- /monitoring/parameter_diffs.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/parameter_diffs.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays parameter values that differ between the current value and the spfile. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @parameter_diffs 8 | -- Last Modified: 08-NOV-2004 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET LINESIZE 120 12 | COLUMN name FORMAT A30 13 | COLUMN current_value FORMAT A30 14 | COLUMN sid FORMAT A8 15 | COLUMN spfile_value FORMAT A30 16 | 17 | SELECT p.name, 18 | i.instance_name AS sid, 19 | p.value AS current_value, 20 | sp.sid, 21 | sp.value AS spfile_value 22 | FROM v$spparameter sp, 23 | v$parameter p, 24 | v$instance i 25 | WHERE sp.name = p.name 26 | AND sp.value != p.value; 27 | 28 | COLUMN FORMAT DEFAULT 29 | -------------------------------------------------------------------------------- /monitoring/parameters.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/parameters.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays a list of all the parameters. 6 | -- Requirements : Access to the v$ views. 7 | -- Call Syntax : @parameters 8 | -- Last Modified: 15-JUL-2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 500 11 | 12 | COLUMN name FORMAT A30 13 | COLUMN value FORMAT A60 14 | 15 | SELECT p.name, 16 | p.type, 17 | p.value, 18 | p.isses_modifiable, 19 | p.issys_modifiable, 20 | p.isinstance_modifiable 21 | FROM v$parameter p 22 | ORDER BY p.name; 23 | 24 | -------------------------------------------------------------------------------- /monitoring/parameters_non_default.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/parameters_non_default.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays a list of all the non-default parameters. 6 | -- Requirements : Access to the v$ views. 7 | -- Call Syntax : @parameters_non_default 8 | -- Last Modified: 11-JAN-2017 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 150 11 | 12 | COLUMN name FORMAT A50 13 | COLUMN value FORMAT A50 14 | 15 | SELECT name, 16 | value 17 | FROM v$parameter 18 | WHERE isdefault = 'FALSE'; 19 | -------------------------------------------------------------------------------- /monitoring/part_tables.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/part_tables.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about all partitioned tables. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @part_tables 8 | -- Last Modified: 21/12/2004 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SELECT owner, table_name, partitioning_type, partition_count 12 | FROM dba_part_tables 13 | WHERE owner NOT IN ('SYS', 'SYSTEM') 14 | ORDER BY owner, table_name; 15 | -------------------------------------------------------------------------------- /monitoring/pga_target_advice.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/pga_target_advice.sql 4 | -- Author : Tim Hall 5 | -- Description : Predicts how changes to the PGA_AGGREGATE_TARGET will affect PGA usage. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @pga_target_advice 8 | -- Last Modified: 12/02/2004 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SELECT ROUND(pga_target_for_estimate/1024/1024) target_mb, 12 | estd_pga_cache_hit_percentage cache_hit_perc, 13 | estd_overalloc_count 14 | FROM v$pga_target_advice; -------------------------------------------------------------------------------- /monitoring/pipes.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/pipes.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays a list of all database pipes. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @pipes 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 100 11 | 12 | COLUMN name FORMAT A40 13 | 14 | SELECT ownerid, 15 | name, 16 | type, 17 | pipe_size 18 | FROM v$db_pipes 19 | ORDER BY 1,2; 20 | 21 | -------------------------------------------------------------------------------- /monitoring/profiler_runs.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/profiler_runs.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information on all profiler_runs. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @profiler_runs.sql 8 | -- Last Modified: 25/02/2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | SET TRIMOUT ON 12 | 13 | COLUMN runid FORMAT 99999 14 | COLUMN run_comment FORMAT A50 15 | 16 | SELECT runid, 17 | run_date, 18 | run_comment, 19 | run_total_time 20 | FROM plsql_profiler_runs 21 | ORDER BY runid; 22 | -------------------------------------------------------------------------------- /monitoring/profiles.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/profiles.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the specified profile(s). 6 | -- Call Syntax : @profiles (profile | part of profile | all) 7 | -- Last Modified: 28/01/2006 8 | -- ----------------------------------------------------------------------------------- 9 | 10 | SET LINESIZE 150 PAGESIZE 20 VERIFY OFF 11 | 12 | BREAK ON profile SKIP 1 13 | 14 | SELECT profile, 15 | resource_type, 16 | resource_name, 17 | limit 18 | FROM dba_profiles 19 | WHERE profile LIKE (DECODE(UPPER('&1'), 'ALL', '%', UPPER('%&1%'))) 20 | ORDER BY profile, resource_type, resource_name; 21 | 22 | CLEAR BREAKS 23 | SET LINESIZE 80 PAGESIZE 14 VERIFY ON 24 | -------------------------------------------------------------------------------- /monitoring/rbs_stats.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/rbs_stats.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays rollback segment statistics. 6 | -- Requirements : Access to the v$ & DBA views. 7 | -- Call Syntax : @rbs_stats 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 500 11 | SET PAGESIZE 1000 12 | SET VERIFY OFF 13 | 14 | SELECT b.name "Segment Name", 15 | Trunc(c.bytes/1024) "Size (Kb)", 16 | a.optsize "Optimal", 17 | a.shrinks "Shrinks", 18 | a.aveshrink "Avg Shrink", 19 | a.wraps "Wraps", 20 | a.extends "Extends" 21 | FROM v$rollstat a, 22 | v$rollname b, 23 | dba_segments c 24 | WHERE a.usn = b.usn 25 | AND b.name = c.segment_name 26 | ORDER BY b.name; 27 | 28 | SET PAGESIZE 14 29 | SET VERIFY ON -------------------------------------------------------------------------------- /monitoring/recovery_status.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/recovery_status.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the recovery status of each datafile. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @recovery_status 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 500 11 | SET PAGESIZE 500 12 | SET FEEDBACK OFF 13 | 14 | SELECT Substr(a.name,1,60) "Datafile", 15 | b.status "Status" 16 | FROM v$datafile a, 17 | v$backup b 18 | WHERE a.file# = b.file#; 19 | 20 | SET PAGESIZE 14 21 | SET FEEDBACK ON -------------------------------------------------------------------------------- /monitoring/recyclebin.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/recyclebin.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the contents of the recyclebin. 6 | -- Requirements : Access to the DBA views. Depending on DB version, different columns 7 | -- are available. 8 | -- Call Syntax : @recyclebin (owner | all) 9 | -- Last Modified: 15/07/2010 10 | -- ----------------------------------------------------------------------------------- 11 | SET LINESIZE 500 VERIFY OFF 12 | 13 | SELECT owner, 14 | original_name, 15 | object_name, 16 | operation, 17 | type, 18 | space AS space_blks, 19 | ROUND((space*8)/1024,2) space_mb 20 | FROM dba_recyclebin 21 | WHERE owner = DECODE(UPPER('&1'), 'ALL', owner, UPPER('&1')) 22 | ORDER BY 1, 2; 23 | 24 | SET VERIFY ON -------------------------------------------------------------------------------- /monitoring/redo_by_day.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/redo_by_day.sql 4 | -- Author : Tim Hall 5 | -- Description : Lists the volume of archived redo by day for the specified number of days. 6 | -- Call Syntax : @redo_by_day (days) 7 | -- Requirements : Access to the v$views. 8 | -- Last Modified: 11/10/2013 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET VERIFY OFF 12 | 13 | SELECT TRUNC(first_time) AS day, 14 | ROUND(SUM(blocks * block_size)/1024/1024/1024,2) size_gb 15 | FROM v$archived_log 16 | WHERE TRUNC(first_time) >= TRUNC(SYSDATE) - &1 17 | GROUP BY TRUNC(first_time) 18 | ORDER BY TRUNC(first_time); 19 | 20 | SET VERIFY ON -------------------------------------------------------------------------------- /monitoring/redo_by_hour.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/redo_by_hour.sql 4 | -- Author : Tim Hall 5 | -- Description : Lists the volume of archived redo by hour for the specified day. 6 | -- Call Syntax : @redo_by_hour (day 0=Today, 1=Yesterday etc.) 7 | -- Requirements : Access to the v$views. 8 | -- Last Modified: 11/10/2013 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET VERIFY OFF PAGESIZE 30 12 | 13 | WITH hours AS ( 14 | SELECT TRUNC(SYSDATE) - &1 + ((level-1)/24) AS hours 15 | FROM dual 16 | CONNECT BY level < = 24 17 | ) 18 | SELECT h.hours AS date_hour, 19 | ROUND(SUM(blocks * block_size)/1024/1024/1024,2) size_gb 20 | FROM hours h 21 | LEFT OUTER JOIN v$archived_log al ON h.hours = TRUNC(al.first_time, 'HH24') 22 | GROUP BY h.hours 23 | ORDER BY h.hours; 24 | 25 | SET VERIFY ON PAGESIZE 14 -------------------------------------------------------------------------------- /monitoring/redo_by_min.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/redo_by_min.sql 4 | -- Author : Tim Hall 5 | -- Description : Lists the volume of archived redo by min for the specified number of hours. 6 | -- Call Syntax : @redo_by_min (N number of minutes from now) 7 | -- Requirements : Access to the v$views. 8 | -- Last Modified: 11/10/2013 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET VERIFY OFF PAGESIZE 100 12 | 13 | WITH mins AS ( 14 | SELECT TRUNC(SYSDATE, 'MI') - (&1/(24*60)) + ((level-1)/(24*60)) AS mins 15 | FROM dual 16 | CONNECT BY level <= &1 17 | ) 18 | SELECT m.mins AS date_min, 19 | ROUND(SUM(blocks * block_size)/1024/1024,2) size_mb 20 | FROM mins m 21 | LEFT OUTER JOIN v$archived_log al ON m.mins = TRUNC(al.first_time, 'MI') 22 | GROUP BY m.mins 23 | ORDER BY m.mins; 24 | 25 | SET VERIFY ON PAGESIZE 14 -------------------------------------------------------------------------------- /monitoring/registry_history.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/registry_history.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays contents of the registry history 6 | -- Requirements : Access to the DBA role. 7 | -- Call Syntax : @registry_history 8 | -- Last Modified: 23/08/2008 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | 12 | COLUMN action_time FORMAT A20 13 | COLUMN action FORMAT A20 14 | COLUMN namespace FORMAT A20 15 | COLUMN version FORMAT A10 16 | COLUMN comments FORMAT A30 17 | COLUMN bundle_series FORMAT A10 18 | 19 | SELECT TO_CHAR(action_time, 'DD-MON-YYYY HH24:MI:SS') AS action_time, 20 | action, 21 | namespace, 22 | version, 23 | id, 24 | comments, 25 | bundle_series 26 | FROM sys.registry$history 27 | ORDER by action_time; -------------------------------------------------------------------------------- /monitoring/roles.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/roles.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays a list of all roles and privileges granted to the specified user. 6 | -- Requirements : Access to the USER views. 7 | -- Call Syntax : @roles 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET SERVEROUTPUT ON 11 | SET VERIFY OFF 12 | 13 | SELECT a.role, 14 | a.password_required, 15 | a.authentication_type 16 | FROM dba_roles a 17 | ORDER BY a.role; 18 | 19 | SET VERIFY ON 20 | -------------------------------------------------------------------------------- /monitoring/search_source.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/search_source.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays a list of all code-objects that contain the specified word. 6 | -- Requirements : Access to the ALL views. 7 | -- Call Syntax : @search_source (text) (schema-name) 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | BREAK ON Name Skip 2 11 | SET PAGESIZE 0 12 | SET LINESIZE 500 13 | SET VERIFY OFF 14 | 15 | SPOOL Search_Source.txt 16 | 17 | SELECT a.name "Name", 18 | a.line "Line", 19 | Substr(a.text,1,200) "Text" 20 | FROM all_source a 21 | WHERE Instr(Upper(a.text),Upper('&&1')) != 0 22 | AND a.owner = Upper('&&2') 23 | ORDER BY 1,2; 24 | 25 | SPOOL OFF 26 | SET PAGESIZE 14 27 | SET VERIFY ON 28 | -------------------------------------------------------------------------------- /monitoring/segment_size.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/segment_size.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays size of specified segment. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @segment_size (owner) (segment_name) 8 | -- Last Modified: 15/07/2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 500 VERIFY OFF 11 | COLUMN segment_name FORMAT A30 12 | 13 | SELECT owner, 14 | segment_name, 15 | segment_type, 16 | tablespace_name, 17 | ROUND(bytes/1024/1024,2) size_mb 18 | FROM dba_segments 19 | WHERE owner = UPPER('&1') 20 | AND segment_name LIKE '%' || UPPER('&2') || '%' 21 | ORDER BY 1, 2; 22 | 23 | SET VERIFY ON -------------------------------------------------------------------------------- /monitoring/segment_stats.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : http://www.oracle-base.com/dba/monitoring/segment_stats.sql 4 | -- Author : DR Timothy S Hall 5 | -- Description : Displays statistics for segments in th specified schema. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @segment_stats 8 | -- Last Modified: 20/10/2006 9 | -- ----------------------------------------------------------------------------------- 10 | SELECT statistic#, 11 | name 12 | FROM v$segstat_name 13 | ORDER BY statistic#; 14 | 15 | ACCEPT l_schema char PROMPT 'Enter Schema: ' 16 | ACCEPT l_stat NUMBER PROMPT 'Enter Statistic#: ' 17 | SET VERIFY OFF 18 | 19 | SELECT object_name, 20 | object_type, 21 | value 22 | FROM v$segment_statistics 23 | WHERE owner = UPPER('&l_schema') 24 | AND statistic# = &l_stat 25 | ORDER BY value; 26 | -------------------------------------------------------------------------------- /monitoring/session_events.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/session_events.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information on all database session events. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @session_events 8 | -- Last Modified: 11/03/2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | SET PAGESIZE 1000 12 | SET VERIFY OFF 13 | 14 | COLUMN username FORMAT A20 15 | COLUMN event FORMAT A40 16 | 17 | SELECT NVL(s.username, '(oracle)') AS username, 18 | s.sid, 19 | s.serial#, 20 | se.event, 21 | se.total_waits, 22 | se.total_timeouts, 23 | se.time_waited, 24 | se.average_wait, 25 | se.max_wait, 26 | se.time_waited_micro 27 | FROM v$session_event se, 28 | v$session s 29 | WHERE s.sid = se.sid 30 | AND s.sid = &1 31 | ORDER BY se.time_waited DESC; 32 | -------------------------------------------------------------------------------- /monitoring/session_io.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/session_io.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays I/O information on all database sessions. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @session_io 8 | -- Last Modified: 21-FEB-2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 500 11 | SET PAGESIZE 1000 12 | 13 | COLUMN username FORMAT A15 14 | 15 | SELECT NVL(s.username, '(oracle)') AS username, 16 | s.osuser, 17 | s.sid, 18 | s.serial#, 19 | si.block_gets, 20 | si.consistent_gets, 21 | si.physical_reads, 22 | si.block_changes, 23 | si.consistent_changes 24 | FROM v$session s, 25 | v$sess_io si 26 | WHERE s.sid = si.sid 27 | ORDER BY s.username, s.osuser; 28 | 29 | SET PAGESIZE 14 30 | -------------------------------------------------------------------------------- /monitoring/session_rollback.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/session_rollback.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays rollback information on relevant database sessions. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @session_rollback 8 | -- Last Modified: 29/03/2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | 12 | COLUMN username FORMAT A15 13 | 14 | SELECT s.username, 15 | s.sid, 16 | s.serial#, 17 | t.used_ublk, 18 | t.used_urec, 19 | rs.segment_name, 20 | r.rssize, 21 | r.status 22 | FROM v$transaction t, 23 | v$session s, 24 | v$rollstat r, 25 | dba_rollback_segs rs 26 | WHERE s.saddr = t.ses_addr 27 | AND t.xidusn = r.usn 28 | AND rs.segment_id = t.xidusn 29 | ORDER BY t.used_ublk DESC; 30 | -------------------------------------------------------------------------------- /monitoring/session_stats.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/session_stats.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays session-specific statistics. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @session_stats (statistic-name or all) 8 | -- Last Modified: 03/11/2004 9 | -- ----------------------------------------------------------------------------------- 10 | SET VERIFY OFF 11 | 12 | SELECT sn.name, ss.value 13 | FROM v$sesstat ss, 14 | v$statname sn, 15 | v$session s 16 | WHERE ss.statistic# = sn.statistic# 17 | AND s.sid = ss.sid 18 | AND s.audsid = SYS_CONTEXT('USERENV','SESSIONID') 19 | AND sn.name LIKE '%' || DECODE(LOWER('&1'), 'all', '', LOWER('&1')) || '%'; 20 | 21 | -------------------------------------------------------------------------------- /monitoring/session_stats_by_sid.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : http://www.oracle-base.com/dba/monitoring/session_stats_by_sid.sql 4 | -- Author : DR Timothy S Hall 5 | -- Description : Displays session-specific statistics. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @session_stats_by_sid (sid) (statistic-name or all) 8 | -- Last Modified: 19/09/2006 9 | -- ----------------------------------------------------------------------------------- 10 | SET VERIFY OFF 11 | 12 | SELECT sn.name, ss.value 13 | FROM v$sesstat ss, 14 | v$statname sn 15 | WHERE ss.statistic# = sn.statistic# 16 | AND ss.sid = &1 17 | AND sn.name LIKE '%' || DECODE(LOWER('&2'), 'all', '', LOWER('&2')) || '%'; 18 | 19 | -------------------------------------------------------------------------------- /monitoring/session_undo.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/session_undo.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays undo information on relevant database sessions. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @session_undo 8 | -- Last Modified: 29/03/2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | 12 | COLUMN username FORMAT A15 13 | 14 | SELECT s.username, 15 | s.sid, 16 | s.serial#, 17 | t.used_ublk, 18 | t.used_urec, 19 | rs.segment_name, 20 | r.rssize, 21 | r.status 22 | FROM v$transaction t, 23 | v$session s, 24 | v$rollstat r, 25 | dba_rollback_segs rs 26 | WHERE s.saddr = t.ses_addr 27 | AND t.xidusn = r.usn 28 | AND rs.segment_id = t.xidusn 29 | ORDER BY t.used_ublk DESC; 30 | -------------------------------------------------------------------------------- /monitoring/session_waits.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/session_waits.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information on all database session waits. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @session_waits 8 | -- Last Modified: 11/03/2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | SET PAGESIZE 1000 12 | 13 | COLUMN username FORMAT A20 14 | COLUMN event FORMAT A30 15 | 16 | SELECT NVL(s.username, '(oracle)') AS username, 17 | s.sid, 18 | s.serial#, 19 | sw.event, 20 | sw.wait_time, 21 | sw.seconds_in_wait, 22 | sw.state 23 | FROM v$session_wait sw, 24 | v$session s 25 | WHERE s.sid = sw.sid 26 | ORDER BY sw.seconds_in_wait DESC; 27 | -------------------------------------------------------------------------------- /monitoring/sessions_by_machine.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/sessions_by_machine.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the number of sessions for each client machine. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @sessions_by_machine 8 | -- Last Modified: 20-JUL-2014 9 | -- ----------------------------------------------------------------------------------- 10 | SET PAGESIZE 1000 11 | 12 | SELECT machine, 13 | NVL(active_count, 0) AS active, 14 | NVL(inactive_count, 0) AS inactive, 15 | NVL(killed_count, 0) AS killed 16 | FROM (SELECT machine, status, count(*) AS quantity 17 | FROM v$session 18 | GROUP BY machine, status) 19 | PIVOT (SUM(quantity) AS count FOR (status) IN ('ACTIVE' AS active, 'INACTIVE' AS inactive, 'KILLED' AS killed)) 20 | ORDER BY machine; 21 | 22 | SET PAGESIZE 14 -------------------------------------------------------------------------------- /monitoring/show_indexes.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : http://www.oracle-base.com/dba/monitoring/show_indexes.sql 4 | -- Author : DR Timothy S Hall 5 | -- Description : Displays information about specified indexes. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @show_indexes (schema) (table-name or all) 8 | -- Last Modified: 04/10/2006 9 | -- ----------------------------------------------------------------------------------- 10 | SET VERIFY OFF 11 | SET LINESIZE 200 12 | 13 | COLUMN table_owner FORMAT A20 14 | COLUMN index_owner FORMAT A20 15 | COLUMN index_type FORMAT A12 16 | COLUMN tablespace_name FORMAT A20 17 | 18 | SELECT table_owner, 19 | table_name, 20 | owner AS index_owner, 21 | index_name, 22 | tablespace_name, 23 | num_rows, 24 | status, 25 | index_type 26 | FROM dba_indexes 27 | WHERE table_owner = UPPER('&1') 28 | AND table_name = DECODE(UPPER('&2'), 'ALL', table_name, UPPER('&2')) 29 | ORDER BY table_owner, table_name, index_owner, index_name; 30 | -------------------------------------------------------------------------------- /monitoring/show_tables.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/show_tables.sql 4 | -- Author : DR Timothy S Hall 5 | -- Description : Displays information about specified tables. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @show_tables (schema) 8 | -- Last Modified: 04/10/2006 9 | -- ----------------------------------------------------------------------------------- 10 | SET VERIFY OFF 11 | SET LINESIZE 200 12 | 13 | COLUMN owner FORMAT A20 14 | COLUMN table_name FORMAT A30 15 | 16 | SELECT t.table_name, 17 | t.tablespace_name, 18 | t.num_rows, 19 | t.avg_row_len, 20 | t.blocks, 21 | t.empty_blocks, 22 | ROUND(t.blocks * ts.block_size/1024/1024,2) AS size_mb 23 | FROM dba_tables t 24 | JOIN dba_tablespaces ts ON t.tablespace_name = ts.tablespace_name 25 | WHERE t.owner = UPPER('&1') 26 | ORDER BY t.table_name; 27 | -------------------------------------------------------------------------------- /monitoring/spfile_parameters.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/spfile_parameters.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays a list of all the spfile parameters. 6 | -- Requirements : Access to the v$ views. 7 | -- Call Syntax : @spfile_parameters 8 | -- Last Modified: 15-JUL-2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 500 11 | 12 | COLUMN name FORMAT A30 13 | COLUMN value FORMAT A60 14 | COLUMN displayvalue FORMAT A60 15 | 16 | SELECT sp.sid, 17 | sp.name, 18 | sp.value, 19 | sp.display_value 20 | FROM v$spparameter sp 21 | ORDER BY sp.name, sp.sid; 22 | -------------------------------------------------------------------------------- /monitoring/sql_area.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/sql_area.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the SQL statements for currently running processes. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @sql_area 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 500 11 | SET PAGESIZE 1000 12 | SET FEEDBACK OFF 13 | 14 | SELECT s.sid, 15 | s.status "Status", 16 | p.spid "Process", 17 | s.schemaname "Schema Name", 18 | s.osuser "OS User", 19 | Substr(a.sql_text,1,120) "SQL Text", 20 | s.program "Program" 21 | FROM v$session s, 22 | v$sqlarea a, 23 | v$process p 24 | WHERE s.sql_hash_value = a.hash_value (+) 25 | AND s.sql_address = a.address (+) 26 | AND s.paddr = p.addr; 27 | 28 | SET PAGESIZE 14 29 | SET FEEDBACK ON 30 | 31 | -------------------------------------------------------------------------------- /monitoring/sql_text.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/sql_text.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the SQL statement held at the specified address. 6 | -- Comments : The address can be found using v$session or Top_SQL.sql. 7 | -- Requirements : Access to the V$ views. 8 | -- Call Syntax : @sql_text (address) 9 | -- Last Modified: 15/07/2000 10 | -- ----------------------------------------------------------------------------------- 11 | SET LINESIZE 500 12 | SET PAGESIZE 1000 13 | SET FEEDBACK OFF 14 | SET VERIFY OFF 15 | 16 | SELECT a.sql_text 17 | FROM v$sqltext_with_newlines a 18 | WHERE a.address = UPPER('&&1') 19 | ORDER BY a.piece; 20 | 21 | PROMPT 22 | SET PAGESIZE 14 23 | SET FEEDBACK ON 24 | -------------------------------------------------------------------------------- /monitoring/sql_text_by_sid.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/sql_text_by_sid.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the SQL statement held for a specific SID. 6 | -- Comments : The SID can be found by running session.sql or top_session.sql. 7 | -- Requirements : Access to the V$ views. 8 | -- Call Syntax : @sql_text_by_sid (sid) 9 | -- Last Modified: 15/07/2000 10 | -- ----------------------------------------------------------------------------------- 11 | SET LINESIZE 500 12 | SET PAGESIZE 1000 13 | SET VERIFY OFF 14 | 15 | SELECT a.sql_text 16 | FROM v$sqltext a, 17 | v$session b 18 | WHERE a.address = b.sql_address 19 | AND a.hash_value = b.sql_hash_value 20 | AND b.sid = &1 21 | ORDER BY a.piece; 22 | 23 | PROMPT 24 | SET PAGESIZE 14 25 | -------------------------------------------------------------------------------- /monitoring/system_events.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/system_events.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information on all system events. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @system_events 8 | -- Last Modified: 21-FEB-2005 9 | -- ----------------------------------------------------------------------------------- 10 | SELECT event, 11 | total_waits, 12 | total_timeouts, 13 | time_waited, 14 | average_wait, 15 | time_waited_micro 16 | FROM v$system_event 17 | ORDER BY event; 18 | -------------------------------------------------------------------------------- /monitoring/system_parameters.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/system_parameters.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays a list of all the system parameters. 6 | -- Comment out isinstance_modifiable for use prior to 10g. 7 | -- Requirements : Access to the v$ views. 8 | -- Call Syntax : @system_parameters 9 | -- Last Modified: 15-JUL-2000 10 | -- ----------------------------------------------------------------------------------- 11 | SET LINESIZE 500 12 | 13 | COLUMN name FORMAT A30 14 | COLUMN value FORMAT A60 15 | 16 | SELECT sp.name, 17 | sp.type, 18 | sp.value, 19 | sp.isses_modifiable, 20 | sp.issys_modifiable, 21 | sp.isinstance_modifiable 22 | FROM v$system_parameter sp 23 | ORDER BY sp.name; 24 | 25 | -------------------------------------------------------------------------------- /monitoring/system_privs.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/system_privs.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays users granted the specified system privilege. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @system_privs ("sys-priv") 8 | -- Last Modified: 27/07/2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 VERIFY OFF 11 | 12 | SELECT privilege, 13 | grantee, 14 | admin_option 15 | FROM dba_sys_privs 16 | WHERE privilege LIKE UPPER('%&1%') 17 | ORDER BY privilege, grantee; 18 | 19 | SET VERIFY ON -------------------------------------------------------------------------------- /monitoring/system_stats.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/system_stats.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays system statistics. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @system_stats (statistic-name or all) 8 | -- Last Modified: 03-NOV-2004 9 | -- ----------------------------------------------------------------------------------- 10 | SET VERIFY OFF 11 | 12 | COLUMN name FORMAT A50 13 | COLUMN value FORMAT 99999999999999999999 14 | 15 | SELECT sn.name, ss.value 16 | FROM v$sysstat ss, 17 | v$statname sn 18 | WHERE ss.statistic# = sn.statistic# 19 | AND sn.name LIKE '%' || DECODE(LOWER('&1'), 'all', '', LOWER('&1')) || '%'; 20 | -------------------------------------------------------------------------------- /monitoring/table_dep.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/table_dep.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays a list dependencies for the specified table. 6 | -- Requirements : Access to the ALL views. 7 | -- Call Syntax : @table_dep (table-name) (schema-name) 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | PROMPT 11 | SET VERIFY OFF 12 | SET FEEDBACK OFF 13 | SET LINESIZE 255 14 | SET PAGESIZE 1000 15 | 16 | 17 | SELECT ad.referenced_name "Object", 18 | ad.name "Ref Object", 19 | ad.type "Type", 20 | Substr(ad.referenced_owner,1,10) "Ref Owner", 21 | Substr(ad.referenced_link_name,1,20) "Ref Link Name" 22 | FROM all_dependencies ad 23 | WHERE ad.referenced_name = Upper('&&1') 24 | AND ad.owner = Upper('&&2') 25 | ORDER BY 1,2,3; 26 | 27 | SET VERIFY ON 28 | SET FEEDBACK ON 29 | SET PAGESIZE 14 30 | PROMPT 31 | -------------------------------------------------------------------------------- /monitoring/table_indexes.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/table_indexes.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays index-column information for the specified table. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @table_indexes (schema-name) (table-name) 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 500 PAGESIZE 1000 VERIFY OFF 11 | 12 | COLUMN index_name FORMAT A30 13 | COLUMN column_name FORMAT A30 14 | COLUMN column_position FORMAT 99999 15 | 16 | SELECT a.index_name, 17 | a.column_name, 18 | a.column_position 19 | FROM all_ind_columns a, 20 | all_indexes b 21 | WHERE b.owner = UPPER('&1') 22 | AND b.table_name = UPPER('&2') 23 | AND b.index_name = a.index_name 24 | AND b.owner = a.index_owner 25 | ORDER BY 1,3; 26 | 27 | SET PAGESIZE 18 VERIFY ON -------------------------------------------------------------------------------- /monitoring/table_partitions.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/table_partitions.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays partition information for the specified table, or all tables. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @table_partitions (table-name or all) (schema-name) 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 500 11 | SET PAGESIZE 1000 12 | SET FEEDBACK OFF 13 | SET VERIFY OFF 14 | 15 | SELECT a.table_name, 16 | a.partition_name, 17 | a.tablespace_name, 18 | a.initial_extent, 19 | a.next_extent, 20 | a.pct_increase, 21 | a.num_rows, 22 | a.avg_row_len 23 | FROM dba_tab_partitions a 24 | WHERE a.table_name = Decode(Upper('&&1'),'ALL',a.table_name,Upper('&&1')) 25 | AND a.table_owner = Upper('&&2') 26 | ORDER BY a.table_name, a.partition_name 27 | / 28 | 29 | 30 | SET PAGESIZE 14 31 | SET FEEDBACK ON 32 | -------------------------------------------------------------------------------- /monitoring/table_triggers.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/table_triggers.sql 4 | -- Author : Tim Hall 5 | -- Description : Lists the triggers for the specified table. 6 | -- Call Syntax : @table_triggers (schema) (table_name) 7 | -- Last Modified: 07/11/2016 8 | -- ----------------------------------------------------------------------------------- 9 | SELECT owner, 10 | trigger_name, 11 | status 12 | FROM dba_triggers 13 | WHERE table_owner = UPPER('&1') 14 | AND table_name = UPPER('&2'); -------------------------------------------------------------------------------- /monitoring/tables_with_locked_stats.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/tables_with_locked_stats.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays tables with locked stats. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @tables_with_locked_stats.sql 8 | -- Last Modified: 06-DEC-2013 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SELECT owner, 12 | table_name, 13 | stattype_locked 14 | FROM dba_tab_statistics 15 | WHERE stattype_locked IS NOT NULL 16 | ORDER BY owner, table_name; 17 | -------------------------------------------------------------------------------- /monitoring/tables_with_zero_rows.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/tables_with_zero_rows.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays tables with stats saying they have zero rows. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @tables_with_zero_rows.sql 8 | -- Last Modified: 06-DEC-2013 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SELECT owner, 12 | table_name, 13 | last_analyzed, 14 | num_rows 15 | FROM dba_tables 16 | WHERE num_rows = 0 17 | AND owner NOT IN ('SYS','SYSTEM','SYSMAN','XDB','MDSYS', 18 | 'WMSYS','OUTLN','ORDDATA','ORDSYS', 19 | 'OLAPSYS','EXFSYS','DBNSMP','CTXSYS', 20 | 'APEX_030200','FLOWS_FILES','SCOTT', 21 | 'TSMSYS','DBSNMP','APPQOSSYS','OWBSYS', 22 | 'DMSYS','FLOWS_030100','WKSYS','WK_TEST') 23 | ORDER BY owner, table_name; 24 | -------------------------------------------------------------------------------- /monitoring/tablespaces.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/tablespaces.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about tablespaces. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @tablespaces 8 | -- Last Modified: 17-AUG-2005 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET LINESIZE 200 12 | 13 | SELECT tablespace_name, 14 | block_size, 15 | extent_management, 16 | allocation_type, 17 | segment_space_management, 18 | status 19 | FROM dba_tablespaces 20 | ORDER BY tablespace_name; 21 | -------------------------------------------------------------------------------- /monitoring/temp_io.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/temp_io.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the amount of IO for each tempfile. 6 | -- Requirements : Access to the v$ views. 7 | -- Call Syntax : @temp_io 8 | -- Last Modified: 15-JUL-2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET PAGESIZE 1000 11 | 12 | SELECT SUBSTR(t.name,1,50) AS file_name, 13 | f.phyblkrd AS blocks_read, 14 | f.phyblkwrt AS blocks_written, 15 | f.phyblkrd + f.phyblkwrt AS total_io 16 | FROM v$tempstat f, 17 | v$tempfile t 18 | WHERE t.file# = f.file# 19 | ORDER BY f.phyblkrd + f.phyblkwrt DESC; 20 | 21 | SET PAGESIZE 18 -------------------------------------------------------------------------------- /monitoring/temp_segments.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/temp_segments.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays a list of all temporary segments. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @temp_segments 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 500 11 | 12 | SELECT owner, 13 | Trunc(Sum(bytes)/1024) Kb 14 | FROM dba_segments 15 | WHERE segment_type = 'TEMPORARY' 16 | GROUP BY owner; 17 | -------------------------------------------------------------------------------- /monitoring/temp_usage.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/temp_usage.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays temp usage for all session currently using temp space. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @temp_usage 8 | -- Last Modified: 12/02/2004 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | 12 | COLUMN temp_used FORMAT 9999999999 13 | 14 | SELECT NVL(s.username, '(background)') AS username, 15 | s.sid, 16 | s.serial#, 17 | ROUND(ss.value/1024/1024, 2) AS temp_used_mb 18 | FROM v$session s 19 | JOIN v$sesstat ss ON s.sid = ss.sid 20 | JOIN v$statname sn ON ss.statistic# = sn.statistic# 21 | WHERE sn.name = 'temp space allocated (bytes)' 22 | AND ss.value > 0 23 | ORDER BY 1; 24 | -------------------------------------------------------------------------------- /monitoring/tempfiles.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/tempfiles.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about tempfiles. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @tempfiles 8 | -- Last Modified: 17-AUG-2005 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET LINESIZE 200 12 | COLUMN file_name FORMAT A70 13 | 14 | SELECT file_id, 15 | file_name, 16 | ROUND(bytes/1024/1024/1024) AS size_gb, 17 | ROUND(maxbytes/1024/1024/1024) AS max_size_gb, 18 | autoextensible, 19 | increment_by, 20 | status 21 | FROM dba_temp_files 22 | ORDER BY file_name; 23 | -------------------------------------------------------------------------------- /monitoring/tempseg_usage.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/tempseg_usage.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays temp segment usage for all session currently using temp space. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @tempseg_usage 8 | -- Last Modified: 01/04/2006 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET LINESIZE 200 12 | COLUMN username FORMAT A20 13 | 14 | SELECT username, 15 | session_addr, 16 | session_num, 17 | sqladdr, 18 | sqlhash, 19 | sql_id, 20 | contents, 21 | segtype, 22 | extents, 23 | blocks 24 | FROM v$tempseg_usage 25 | ORDER BY username; -------------------------------------------------------------------------------- /monitoring/top_latches.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/top_latches.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about the top latches. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @top_latches 8 | -- Last Modified: 15-JUL-2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | 12 | SELECT l.latch#, 13 | l.name, 14 | l.gets, 15 | l.misses, 16 | l.sleeps, 17 | l.immediate_gets, 18 | l.immediate_misses, 19 | l.spin_gets 20 | FROM v$latch l 21 | WHERE l.misses > 0 22 | ORDER BY l.misses DESC; 23 | -------------------------------------------------------------------------------- /monitoring/top_sql.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/top_sql.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays a list of SQL statements that are using the most resources. 6 | -- Comments : The address column can be use as a parameter with SQL_Text.sql to display the full statement. 7 | -- Requirements : Access to the V$ views. 8 | -- Call Syntax : @top_sql (number) 9 | -- Last Modified: 15/07/2000 10 | -- ----------------------------------------------------------------------------------- 11 | SET LINESIZE 500 12 | SET PAGESIZE 1000 13 | SET VERIFY OFF 14 | 15 | SELECT * 16 | FROM (SELECT Substr(a.sql_text,1,50) sql_text, 17 | Trunc(a.disk_reads/Decode(a.executions,0,1,a.executions)) reads_per_execution, 18 | a.buffer_gets, 19 | a.disk_reads, 20 | a.executions, 21 | a.sorts, 22 | a.address 23 | FROM v$sqlarea a 24 | ORDER BY 2 DESC) 25 | WHERE rownum <= &&1; 26 | 27 | SET PAGESIZE 14 28 | -------------------------------------------------------------------------------- /monitoring/trace_run_details.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/trace_run_details.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays details of a specified trace run. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @trace_run_details.sql (runid) 8 | -- Last Modified: 06/05/2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | SET TRIMOUT ON 12 | 13 | COLUMN runid FORMAT 99999 14 | COLUMN event_seq FORMAT 99999 15 | COLUMN event_unit_owner FORMAT A20 16 | COLUMN event_unit FORMAT A20 17 | COLUMN event_unit_kind FORMAT A20 18 | COLUMN event_comment FORMAT A30 19 | 20 | SELECT e.runid, 21 | e.event_seq, 22 | TO_CHAR(e.event_time, 'DD-MON-YYYY HH24:MI:SS') AS event_time, 23 | e.event_unit_owner, 24 | e.event_unit, 25 | e.event_unit_kind, 26 | e.proc_line, 27 | e.event_comment 28 | FROM plsql_trace_events e 29 | WHERE e.runid = &1 30 | ORDER BY e.runid, e.event_seq; -------------------------------------------------------------------------------- /monitoring/trace_runs.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/trace_runs.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information on all trace runs. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @trace_runs.sql 8 | -- Last Modified: 06/05/2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | SET TRIMOUT ON 12 | 13 | COLUMN runid FORMAT 99999 14 | 15 | SELECT runid, 16 | run_date, 17 | run_owner 18 | FROM plsql_trace_runs 19 | ORDER BY runid; -------------------------------------------------------------------------------- /monitoring/ts_datafiles.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/ts_datafiles.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information about datafiles for the specified tablespace. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @ts_datafiles (tablespace-name) 8 | -- Last Modified: 17-AUG-2005 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET LINESIZE 200 12 | COLUMN file_name FORMAT A70 13 | 14 | SELECT file_id, 15 | file_name, 16 | ROUND(bytes/1024/1024/1024) AS size_gb, 17 | ROUND(maxbytes/1024/1024/1024) AS max_size_gb, 18 | autoextensible, 19 | increment_by, 20 | status 21 | FROM dba_data_files 22 | WHERE tablespace_name = UPPER('&1') 23 | ORDER BY file_id; 24 | -------------------------------------------------------------------------------- /monitoring/ts_thresholds.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/ts_thresholds.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays threshold information for tablespaces. 6 | -- Call Syntax : @ts_thresholds 7 | -- Last Modified: 13/02/2014 - Created 8 | -- ----------------------------------------------------------------------------------- 9 | SET LINESIZE 200 10 | 11 | COLUMN metrics_name FORMAT A30 12 | COLUMN warning_value FORMAT A30 13 | COLUMN critical_value FORMAT A15 14 | 15 | SELECT tablespace_name, 16 | contents, 17 | extent_management, 18 | threshold_type, 19 | metrics_name, 20 | warning_operator, 21 | warning_value, 22 | critical_operator, 23 | critical_value 24 | FROM dba_tablespace_thresholds 25 | ORDER BY tablespace_name; 26 | 27 | SET LINESIZE 80 28 | -------------------------------------------------------------------------------- /monitoring/unusable_indexes.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/unusable_indexes.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays unusable indexes for the specified schema or all schemas. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @unusable_indexes (schema-name or all) 8 | -- Last Modified: 05/11/2004 9 | -- ----------------------------------------------------------------------------------- 10 | SET VERIFY OFF 11 | 12 | SELECT owner, 13 | index_name 14 | FROM dba_indexes 15 | WHERE owner = DECODE(UPPER('&1'), 'ALL', owner, UPPER('&1')) 16 | AND status NOT IN ('VALID', 'N/A') 17 | ORDER BY owner, index_name; 18 | 19 | -------------------------------------------------------------------------------- /monitoring/user_hit_ratio.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/user_hit_ratio.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the Cache Hit Ratio per user. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @user_hit_ratio 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 500 11 | COLUMN "Hit Ratio %" FORMAT 999.99 12 | 13 | SELECT a.username "Username", 14 | b.consistent_gets "Consistent Gets", 15 | b.block_gets "DB Block Gets", 16 | b.physical_reads "Physical Reads", 17 | Round(100* (b.consistent_gets + b.block_gets - b.physical_reads) / 18 | (b.consistent_gets + b.block_gets),2) "Hit Ratio %" 19 | FROM v$session a, 20 | v$sess_io b 21 | WHERE a.sid = b.sid 22 | AND (b.consistent_gets + b.block_gets) > 0 23 | AND a.username IS NOT NULL; 24 | -------------------------------------------------------------------------------- /monitoring/user_roles.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/user_roles.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays a list of all roles and privileges granted to the specified user. 6 | -- Requirements : Access to the USER views. 7 | -- Call Syntax : @user_roles 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET SERVEROUTPUT ON 11 | SET VERIFY OFF 12 | 13 | SELECT a.granted_role, 14 | a.admin_option 15 | FROM user_role_privs a 16 | ORDER BY a.granted_role; 17 | 18 | SELECT a.privilege, 19 | a.admin_option 20 | FROM user_sys_privs a 21 | ORDER BY a.privilege; 22 | 23 | SET VERIFY ON 24 | -------------------------------------------------------------------------------- /monitoring/user_system_privs.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/user_system_privs.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays system privileges granted to a specified user. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @user_system_privs (user-name) 8 | -- Last Modified: 27/07/2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 VERIFY OFF 11 | 12 | SELECT grantee, 13 | privilege, 14 | admin_option 15 | FROM dba_sys_privs 16 | WHERE grantee = UPPER('&1') 17 | ORDER BY grantee, privilege; 18 | 19 | SET VERIFY ON -------------------------------------------------------------------------------- /monitoring/user_temp_space.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : http://www.oracle-base.com/dba/monitoring/user_temp_space.sql 4 | -- Author : DR Timothy S Hall 5 | -- Description : Displays the temp space currently in use by users. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @user_temp_space 8 | -- Last Modified: 12/02/2004 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | COLUMN tablespace FORMAT A20 12 | COLUMN temp_size FORMAT A20 13 | COLUMN sid_serial FORMAT A20 14 | COLUMN username FORMAT A20 15 | COLUMN program FORMAT A40 16 | SET LINESIZE 200 17 | 18 | SELECT b.tablespace, 19 | ROUND(((b.blocks*p.value)/1024/1024),2)||'M' AS temp_size, 20 | a.sid||','||a.serial# AS sid_serial, 21 | NVL(a.username, '(oracle)') AS username, 22 | a.program 23 | FROM v$session a, 24 | v$sort_usage b, 25 | v$parameter p 26 | WHERE p.name = 'db_block_size' 27 | AND a.saddr = b.session_addr 28 | ORDER BY b.tablespace, b.blocks; 29 | -------------------------------------------------------------------------------- /monitoring/user_undo_space.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/user_undo_space.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the undo space currently in use by users. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @user_undo_space 8 | -- Last Modified: 12/02/2004 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | COLUMN sid_serial FORMAT A20 12 | COLUMN username FORMAT A20 13 | COLUMN program FORMAT A30 14 | COLUMN undoseg FORMAT A25 15 | COLUMN undo FORMAT A20 16 | SET LINESIZE 120 17 | 18 | SELECT TO_CHAR(s.sid)||','||TO_CHAR(s.serial#) AS sid_serial, 19 | NVL(s.username, '(oracle)') AS username, 20 | s.program, 21 | r.name undoseg, 22 | t.used_ublk * TO_NUMBER(x.value)/1024||'K' AS undo 23 | FROM v$rollname r, 24 | v$session s, 25 | v$transaction t, 26 | v$parameter x 27 | WHERE s.taddr = t.addr 28 | AND r.usn = t.xidusn(+) 29 | AND x.name = 'db_block_size'; -------------------------------------------------------------------------------- /monitoring/users_with_role.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/users_with_role.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays a list of users granted the specified role. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @user_with_role DBA 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET VERIFY OFF 12 | COLUMN username FORMAT A30 13 | 14 | SELECT username, 15 | lock_date, 16 | expiry_date 17 | FROM dba_users 18 | WHERE username IN (SELECT grantee 19 | FROM dba_role_privs 20 | WHERE granted_role = UPPER('&1')) 21 | ORDER BY username; 22 | 23 | SET VERIFY ON -------------------------------------------------------------------------------- /monitoring/users_with_sys_priv.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/users_with_sys_priv.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays a list of users granted the specified role. 6 | -- Requirements : Access to the DBA views. 7 | -- Call Syntax : @users_with_sys_priv "UNLIMITED TABLESPACE" 8 | -- Last Modified: 15/07/2000 9 | -- ----------------------------------------------------------------------------------- 10 | 11 | SET VERIFY OFF 12 | COLUMN username FORMAT A30 13 | 14 | SELECT username, 15 | lock_date, 16 | expiry_date 17 | FROM dba_users 18 | WHERE username IN (SELECT grantee 19 | FROM dba_sys_privs 20 | WHERE privilege = UPPER('&1')) 21 | ORDER BY username; 22 | -------------------------------------------------------------------------------- /rac/monitor_memory_rac.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/monitor_memory_rac.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays memory allocations for the current database sessions for the whole RAC. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @monitor_memory_rac 8 | -- Last Modified: 15-JUL-2000 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | 12 | COLUMN username FORMAT A20 13 | COLUMN module FORMAT A20 14 | 15 | SELECT a.inst_id, 16 | NVL(a.username,'(oracle)') AS username, 17 | a.module, 18 | a.program, 19 | Trunc(b.value/1024) AS memory_kb 20 | FROM gv$session a, 21 | gv$sesstat b, 22 | gv$statname c 23 | WHERE a.sid = b.sid 24 | AND a.inst_id = b.inst_id 25 | AND b.statistic# = c.statistic# 26 | AND b.inst_id = c.inst_id 27 | AND c.name = 'session pga memory' 28 | AND a.program IS NOT NULL 29 | ORDER BY b.value DESC; -------------------------------------------------------------------------------- /rac/session_undo_rac.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/monitoring/session_undo_rac.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays undo information on relevant database sessions. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @session_undo_rac 8 | -- Last Modified: 20/12/2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | 12 | COLUMN username FORMAT A15 13 | 14 | SELECT s.inst_id, 15 | s.username, 16 | s.sid, 17 | s.serial#, 18 | t.used_ublk, 19 | t.used_urec, 20 | rs.segment_name, 21 | r.rssize, 22 | r.status 23 | FROM gv$transaction t, 24 | gv$session s, 25 | gv$rollstat r, 26 | dba_rollback_segs rs 27 | WHERE s.saddr = t.ses_addr 28 | AND s.inst_id = t.inst_id 29 | AND t.xidusn = r.usn 30 | AND t.inst_id = r.inst_id 31 | AND rs.segment_id = t.xidusn 32 | ORDER BY t.used_ublk DESC; 33 | -------------------------------------------------------------------------------- /rac/session_waits_rac.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/10g/session_waits_rac.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays information on all database session waits for the whole RAC. 6 | -- Requirements : Access to the V$ views. 7 | -- Call Syntax : @session_waits_rac 8 | -- Last Modified: 02/07/2005 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | SET PAGESIZE 1000 12 | 13 | COLUMN username FORMAT A20 14 | COLUMN event FORMAT A30 15 | COLUMN wait_class FORMAT A15 16 | 17 | SELECT s.inst_id, 18 | NVL(s.username, '(oracle)') AS username, 19 | s.sid, 20 | s.serial#, 21 | sw.event, 22 | sw.wait_class, 23 | sw.wait_time, 24 | sw.seconds_in_wait, 25 | sw.state 26 | FROM gv$session_wait sw, 27 | gv$session s 28 | WHERE s.sid = sw.sid 29 | AND s.inst_id = sw.inst_id 30 | ORDER BY sw.seconds_in_wait DESC; 31 | -------------------------------------------------------------------------------- /resource_manager/active_plan.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/resource_manager/active_plan.sql 4 | -- Author : Tim Hall 5 | -- Description : Lists the currently active resource plan if one is set. 6 | -- Call Syntax : @active_plan 7 | -- Requirements : Access to the v$ views. 8 | -- Last Modified: 12/11/2004 9 | -- ----------------------------------------------------------------------------------- 10 | SELECT name, 11 | is_top_plan 12 | FROM v$rsrc_plan 13 | ORDER BY name; 14 | -------------------------------------------------------------------------------- /resource_manager/consumer_group_usage.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/resource_manager/consumer_group_usage.sql 4 | -- Author : Tim Hall 5 | -- Description : Lists usage information of consumer groups. 6 | -- Call Syntax : @consumer_group_usage 7 | -- Requirements : Access to the v$ views. 8 | -- Last Modified: 12/11/2004 9 | -- ----------------------------------------------------------------------------------- 10 | SELECT name, 11 | consumed_cpu_time 12 | FROM v$rsrc_consumer_group 13 | ORDER BY name; 14 | -------------------------------------------------------------------------------- /resource_manager/consumer_groups.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/resource_manager/consumer_groups.sql 4 | -- Author : Tim Hall 5 | -- Description : Lists all consumer groups. 6 | -- Call Syntax : @consumer_groups 7 | -- Requirements : Access to the DBA views. 8 | -- Last Modified: 12/11/2004 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | SET VERIFY OFF 12 | 13 | COLUMN status FORMAT A10 14 | COLUMN comments FORMAT A50 15 | 16 | SELECT consumer_group, 17 | status, 18 | comments 19 | FROM dba_rsrc_consumer_groups 20 | ORDER BY consumer_group; -------------------------------------------------------------------------------- /resource_manager/plan_directives.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/resource_manager/plan_directives.sql 4 | -- Author : Tim Hall 5 | -- Description : Lists all plan directives. 6 | -- Call Syntax : @plan_directives (plan-name or all) 7 | -- Requirements : Access to the DBA views. 8 | -- Last Modified: 12/11/2004 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | SET VERIFY OFF 12 | 13 | SELECT plan, 14 | group_or_subplan, 15 | cpu_p1, 16 | cpu_p2, 17 | cpu_p3, 18 | cpu_p4 19 | FROM dba_rsrc_plan_directives 20 | WHERE plan = DECODE(UPPER('&1'), 'ALL', plan, UPPER('&1')) 21 | ORDER BY plan, cpu_p1 DESC, cpu_p2 DESC, cpu_p3 DESC; 22 | -------------------------------------------------------------------------------- /resource_manager/resource_plans.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/resource_manager/resource_plans.sql 4 | -- Author : Tim Hall 5 | -- Description : Lists all resource plans. 6 | -- Call Syntax : @resource_plans 7 | -- Requirements : Access to the DBA views. 8 | -- Last Modified: 12/11/2004 9 | -- ----------------------------------------------------------------------------------- 10 | SET LINESIZE 200 11 | SET VERIFY OFF 12 | 13 | COLUMN status FORMAT A10 14 | COLUMN comments FORMAT A50 15 | 16 | SELECT plan, 17 | status, 18 | comments 19 | FROM dba_rsrc_plans 20 | ORDER BY plan; -------------------------------------------------------------------------------- /script_creation/db_link_ddl.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/script_creation/db_link_ddl.sql 4 | -- Author : Tim Hall 5 | -- Description : Creates the DDL for DB links for the specific schema, or all schemas. 6 | -- Call Syntax : @db_link_ddl (schema or all) 7 | -- Last Modified: 16/03/2013 8 | -- ----------------------------------------------------------------------------------- 9 | SET LONG 20000 LONGCHUNKSIZE 20000 PAGESIZE 0 LINESIZE 1000 FEEDBACK OFF VERIFY OFF TRIMSPOOL ON 10 | 11 | BEGIN 12 | DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'SQLTERMINATOR', true); 13 | DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'PRETTY', true); 14 | END; 15 | / 16 | 17 | SELECT DBMS_METADATA.get_ddl ('DB_LINK', db_link, owner) 18 | FROM dba_db_links 19 | WHERE owner = DECODE(UPPER('&1'), 'ALL', owner, UPPER('&1')); 20 | 21 | SET PAGESIZE 14 LINESIZE 1000 FEEDBACK ON VERIFY ON -------------------------------------------------------------------------------- /script_creation/directory_ddl.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/script_creation/directory_ddl.sql 4 | -- Author : Tim Hall 5 | -- Description : Creates the DDL for specified directory, or all directories. 6 | -- Call Syntax : @directory_ddl (directory or all) 7 | -- Last Modified: 16/03/2013 8 | -- ----------------------------------------------------------------------------------- 9 | SET LONG 20000 LONGCHUNKSIZE 20000 PAGESIZE 0 LINESIZE 1000 FEEDBACK OFF VERIFY OFF TRIMSPOOL ON 10 | 11 | BEGIN 12 | DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'SQLTERMINATOR', true); 13 | DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'PRETTY', true); 14 | END; 15 | / 16 | 17 | SELECT DBMS_METADATA.get_ddl ('DIRECTORY', directory_name) 18 | FROM dba_directories 19 | WHERE directory_name = DECODE(UPPER('&1'), 'ALL', directory_name, UPPER('&1')); 20 | 21 | SET PAGESIZE 14 LINESIZE 1000 FEEDBACK ON VERIFY ON -------------------------------------------------------------------------------- /script_creation/index_monitoring_off.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/script_creation/index_monitoring_on.sql 4 | -- Author : Tim Hall 5 | -- Description : Sets monitoring off for the specified table indexes. 6 | -- Call Syntax : @index_monitoring_on (schema) (table-name or all) 7 | -- Last Modified: 04/02/2005 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | SPOOL temp.sql 13 | 14 | SELECT 'ALTER INDEX "' || i.owner || '"."' || i.index_name || '" NOMONITORING USAGE;' 15 | FROM dba_indexes i 16 | WHERE owner = UPPER('&1') 17 | AND table_name = DECODE(UPPER('&2'), 'ALL', table_name, UPPER('&2')); 18 | 19 | SPOOL OFF 20 | 21 | SET PAGESIZE 18 22 | SET FEEDBACK ON 23 | 24 | @temp.sql 25 | 26 | -------------------------------------------------------------------------------- /script_creation/index_monitoring_on.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/script_creation/index_monitoring_on.sql 4 | -- Author : Tim Hall 5 | -- Description : Sets monitoring on for the specified table indexes. 6 | -- Call Syntax : @index_monitoring_on (schema) (table-name or all) 7 | -- Last Modified: 04/02/2005 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | SPOOL temp.sql 13 | 14 | SELECT 'ALTER INDEX "' || i.owner || '"."' || i.index_name || '" MONITORING USAGE;' 15 | FROM dba_indexes i 16 | WHERE owner = UPPER('&1') 17 | AND table_name = DECODE(UPPER('&2'), 'ALL', table_name, UPPER('&2')); 18 | 19 | SPOOL OFF 20 | 21 | SET PAGESIZE 18 22 | SET FEEDBACK ON 23 | 24 | @temp.sql 25 | 26 | -------------------------------------------------------------------------------- /script_creation/monitoring_off.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/script_creation/monitoring_on.sql 4 | -- Author : Tim Hall 5 | -- Description : Sets monitoring off for the specified tables. 6 | -- Call Syntax : @monitoring_on (schema) (table-name or all) 7 | -- Last Modified: 21/03/2003 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | SPOOL temp.sql 13 | 14 | SELECT 'ALTER TABLE "' || owner || '"."' || table_name || '" NOMONITORING;' 15 | FROM dba_tables 16 | WHERE owner = UPPER('&1') 17 | AND table_name = DECODE(UPPER('&2'), 'ALL', table_name, UPPER('&2')) 18 | AND monitoring = 'YES'; 19 | 20 | SPOOL OFF 21 | 22 | SET PAGESIZE 18 23 | SET FEEDBACK ON 24 | 25 | @temp.sql 26 | 27 | -------------------------------------------------------------------------------- /script_creation/monitoring_on.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/script_creation/monitoring_on.sql 4 | -- Author : Tim Hall 5 | -- Description : Sets monitoring on for the specified tables. 6 | -- Call Syntax : @monitoring_on (schema) (table-name or all) 7 | -- Last Modified: 21/03/2003 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | SPOOL temp.sql 13 | 14 | SELECT 'ALTER TABLE "' || owner || '"."' || table_name || '" MONITORING;' 15 | FROM dba_tables 16 | WHERE owner = UPPER('&1') 17 | AND table_name = DECODE(UPPER('&2'), 'ALL', table_name, UPPER('&2')) 18 | AND monitoring != 'YES'; 19 | 20 | SPOOL OFF 21 | 22 | SET PAGESIZE 18 23 | SET FEEDBACK ON 24 | 25 | @temp.sql 26 | 27 | -------------------------------------------------------------------------------- /script_creation/object_grants.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/script_creation/object_grants.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the DDL for all grants on a specific object. 6 | -- Call Syntax : @object_grants (owner) (object_name) 7 | -- Last Modified: 28/01/2006 8 | -- ----------------------------------------------------------------------------------- 9 | 10 | set long 1000000 linesize 1000 pagesize 0 feedback off trimspool on verify off 11 | column ddl format a1000 12 | 13 | begin 14 | dbms_metadata.set_transform_param (dbms_metadata.session_transform, 'SQLTERMINATOR', true); 15 | dbms_metadata.set_transform_param (dbms_metadata.session_transform, 'PRETTY', true); 16 | end; 17 | / 18 | 19 | select dbms_metadata.get_dependent_ddl('OBJECT_GRANT', UPPER('&2'), UPPER('&1')) AS ddl 20 | from dual; 21 | 22 | set linesize 80 pagesize 14 feedback on trimspool on verify on 23 | -------------------------------------------------------------------------------- /script_creation/profile_ddl.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/script_creation/profile_ddl.sql 4 | -- Author : Tim Hall 5 | -- Description : Displays the DDL for the specified profile(s). 6 | -- Call Syntax : @profile_ddl (profile | part of profile) 7 | -- Last Modified: 28/01/2006 8 | -- ----------------------------------------------------------------------------------- 9 | 10 | set long 20000 longchunksize 20000 pagesize 0 linesize 1000 feedback off verify off trimspool on 11 | column ddl format a1000 12 | 13 | begin 14 | dbms_metadata.set_transform_param (dbms_metadata.session_transform, 'SQLTERMINATOR', true); 15 | dbms_metadata.set_transform_param (dbms_metadata.session_transform, 'PRETTY', true); 16 | end; 17 | / 18 | 19 | select dbms_metadata.get_ddl('PROFILE', profile) as profile_ddl 20 | from (select distinct profile 21 | from dba_profiles) 22 | where profile like upper('%&1%'); 23 | 24 | set linesize 80 pagesize 14 feedback on verify on 25 | -------------------------------------------------------------------------------- /script_creation/synonym_public_remote_ddl.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/script_creation/synonym_public_remote_ddl.sql 4 | -- Author : Tim Hall 5 | -- Description : Creates the DDL for public synonyms to remote objects. 6 | -- Call Syntax : @synonym_remote_ddl 7 | -- Last Modified: 08/07/2013 - Rewritten to use DBMS_METADATA 8 | -- ----------------------------------------------------------------------------------- 9 | SET LONG 20000 LONGCHUNKSIZE 20000 PAGESIZE 0 LINESIZE 1000 FEEDBACK OFF VERIFY OFF TRIMSPOOL ON 10 | 11 | BEGIN 12 | DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'SQLTERMINATOR', true); 13 | DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'PRETTY', true); 14 | END; 15 | / 16 | 17 | SELECT DBMS_METADATA.get_ddl ('SYNONYM', synonym_name, owner) 18 | FROM dba_synonyms 19 | WHERE owner = 'PUBLIC' 20 | AND db_link IS NOT NULL; 21 | 22 | SET PAGESIZE 14 FEEDBACK ON VERIFY ON -------------------------------------------------------------------------------- /script_creation/table_grants_ddl.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/script_creation/table_grants_ddl.sql 4 | -- Author : Tim Hall 5 | -- Description : Creates the DDL for all grants on the specified table. 6 | -- Call Syntax : @table_grants_ddl (schema) (table_name) 7 | -- Last Modified: 16/03/2013 - Rewritten to use DBMS_METADATA 8 | -- ----------------------------------------------------------------------------------- 9 | SET LONG 20000 LONGCHUNKSIZE 20000 PAGESIZE 0 LINESIZE 1000 FEEDBACK OFF VERIFY OFF TRIMSPOOL ON 10 | 11 | BEGIN 12 | DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'SQLTERMINATOR', true); 13 | DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'PRETTY', true); 14 | END; 15 | / 16 | 17 | SELECT dbms_metadata.get_dependent_ddl('OBJECT_GRANT', UPPER('&2'), UPPER('&1')) from dual; 18 | 19 | SET PAGESIZE 14 LINESIZE 100 FEEDBACK ON VERIFY ON -------------------------------------------------------------------------------- /script_creation/table_triggers_ddl.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/script_creation/table_triggers_ddl.sql 4 | -- Author : Tim Hall 5 | -- Description : Creates the DDL for all triggers on the specified table. 6 | -- Call Syntax : @table_triggers_ddl (schema) (table_name) 7 | -- Last Modified: 16/03/2013 - Rewritten to use DBMS_METADATA 8 | -- ----------------------------------------------------------------------------------- 9 | SET LONG 20000 LONGCHUNKSIZE 20000 PAGESIZE 0 LINESIZE 1000 FEEDBACK OFF VERIFY OFF TRIMSPOOL ON 10 | 11 | BEGIN 12 | DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'SQLTERMINATOR', true); 13 | DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'PRETTY', true); 14 | END; 15 | / 16 | 17 | SELECT DBMS_METADATA.get_ddl ('TRIGGER', trigger_name, owner) 18 | FROM all_triggers 19 | WHERE table_owner = UPPER('&1') 20 | AND table_name = UPPER('&2'); 21 | 22 | SET PAGESIZE 14 LINESIZE 100 FEEDBACK ON VERIFY ON -------------------------------------------------------------------------------- /script_creation/tablespace_ddl.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/script_creation/tablespace_ddl.sql 4 | -- Author : Tim Hall 5 | -- Description : Creates the DDL for the specified tablespace, or all tablespaces. 6 | -- Call Syntax : @tablespace_ddl (tablespace-name or all) 7 | -- Last Modified: 16/03/2013 - Rewritten to use DBMS_METADATA 8 | -- ----------------------------------------------------------------------------------- 9 | SET LONG 20000 LONGCHUNKSIZE 20000 PAGESIZE 0 LINESIZE 1000 FEEDBACK OFF VERIFY OFF TRIMSPOOL ON 10 | 11 | BEGIN 12 | DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'SQLTERMINATOR', true); 13 | DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'PRETTY', true); 14 | END; 15 | / 16 | 17 | SELECT DBMS_METADATA.get_ddl ('TABLESPACE', tablespace_name) 18 | FROM dba_tablespaces 19 | WHERE tablespace_name = DECODE(UPPER('&1'), 'ALL', tablespace_name, UPPER('&1')); 20 | 21 | SET PAGESIZE 14 LINESIZE 100 FEEDBACK ON VERIFY ON -------------------------------------------------------------------------------- /script_creation/tablespace_structure.sql: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /script_creation/trigger_ddl.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/script_creation/trigger_ddl.sql 4 | -- Author : Tim Hall 5 | -- Description : Creates the DDL for specified trigger, or all trigger. 6 | -- Call Syntax : @trigger_ddl (schema) (trigger-name or all) 7 | -- Last Modified: 16/03/2013 - Rewritten to use DBMS_METADATA 8 | -- ----------------------------------------------------------------------------------- 9 | SET LONG 20000 LONGCHUNKSIZE 20000 PAGESIZE 0 LINESIZE 1000 FEEDBACK OFF VERIFY OFF TRIMSPOOL ON 10 | 11 | BEGIN 12 | DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'SQLTERMINATOR', true); 13 | DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'PRETTY', true); 14 | END; 15 | / 16 | 17 | SELECT DBMS_METADATA.get_ddl ('TRIGGER', trigger_name, owner) 18 | FROM all_triggers 19 | WHERE owner = UPPER('&1') 20 | AND trigger_name = DECODE(UPPER('&2'), 'ALL', trigger_name, UPPER('&2')); 21 | 22 | SET PAGESIZE 14 LINESIZE 100 FEEDBACK ON VERIFY ON -------------------------------------------------------------------------------- /script_creation/view_ddl.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/script_creation/view_ddl.sql 4 | -- Author : Tim Hall 5 | -- Description : Creates the DDL for the specified view. 6 | -- Call Syntax : @view_ddl (schema-name) (view-name) 7 | -- Last Modified: 16/03/2013 - Rewritten to use DBMS_METADATA 8 | -- ----------------------------------------------------------------------------------- 9 | SET LONG 20000 LONGCHUNKSIZE 20000 PAGESIZE 0 LINESIZE 1000 FEEDBACK OFF VERIFY OFF TRIMSPOOL ON 10 | 11 | BEGIN 12 | DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'SQLTERMINATOR', true); 13 | DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'PRETTY', true); 14 | END; 15 | / 16 | 17 | SELECT DBMS_METADATA.get_ddl ('VIEW', view_name, owner) 18 | FROM all_views 19 | WHERE owner = UPPER('&1') 20 | AND view_name = DECODE(UPPER('&2'), 'ALL', view_name, UPPER('&2')); 21 | 22 | SET PAGESIZE 14 LINESIZE 100 FEEDBACK ON VERIFY ON -------------------------------------------------------------------------------- /security/grant_delete.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/security/grant_delete.sql 4 | -- Author : Tim Hall 5 | -- Description : Grants delete on current schemas tables to the specified user/role. 6 | -- Call Syntax : @grant_delete (schema-name) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'GRANT DELETE ON "' || u.table_name || '" TO &1;' 16 | FROM user_tables u 17 | WHERE NOT EXISTS (SELECT '1' 18 | FROM all_tab_privs a 19 | WHERE a.grantee = UPPER('&1') 20 | AND a.privilege = 'DELETE' 21 | AND a.table_name = u.table_name); 22 | 23 | SPOOL OFF 24 | 25 | @temp.sql 26 | 27 | -- Comment out following line to prevent immediate run 28 | @temp.sql 29 | 30 | SET PAGESIZE 14 31 | SET FEEDBACK ON 32 | SET VERIFY ON 33 | -------------------------------------------------------------------------------- /security/grant_execute.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/security/grant_execute.sql 4 | -- Author : Tim Hall 5 | -- Description : Grants execute on current schemas code objects to the specified user/role. 6 | -- Call Syntax : @grant_execute (schema-name) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'GRANT EXECUTE ON "' || u.object_name || '" TO &1;' 16 | FROM user_objects u 17 | WHERE u.object_type IN ('PACKAGE','PROCEDURE','FUNCTION') 18 | AND NOT EXISTS (SELECT '1' 19 | FROM all_tab_privs a 20 | WHERE a.grantee = UPPER('&1') 21 | AND a.privilege = 'EXECUTE' 22 | AND a.table_name = u.object_name); 23 | 24 | SPOOL OFF 25 | 26 | -- Comment out following line to prevent immediate run 27 | @temp.sql 28 | 29 | SET PAGESIZE 14 30 | SET FEEDBACK ON 31 | SET VERIFY ON 32 | -------------------------------------------------------------------------------- /security/grant_insert.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/security/grant_insert.sql 4 | -- Author : Tim Hall 5 | -- Description : Grants insert on current schemas tables to the specified user/role. 6 | -- Call Syntax : @grant_insert (schema-name) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'GRANT INSERT ON "' || u.table_name || '" TO &1;' 16 | FROM user_tables u 17 | WHERE NOT EXISTS (SELECT '1' 18 | FROM all_tab_privs a 19 | WHERE a.grantee = UPPER('&1') 20 | AND a.privilege = 'INSERT' 21 | AND a.table_name = u.table_name); 22 | 23 | SPOOL OFF 24 | 25 | -- Comment out following line to prevent immediate run 26 | @temp.sql 27 | 28 | SET PAGESIZE 14 29 | SET FEEDBACK ON 30 | SET VERIFY ON 31 | -------------------------------------------------------------------------------- /security/grant_select.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/security/grant_select.sql 4 | -- Author : Tim Hall 5 | -- Description : Grants select on current schemas tables, views & sequences to the specified user/role. 6 | -- Call Syntax : @grant_select (schema-name) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'GRANT SELECT ON "' || u.object_name || '" TO &1;' 16 | FROM user_objects u 17 | WHERE u.object_type IN ('TABLE','VIEW','SEQUENCE') 18 | AND NOT EXISTS (SELECT '1' 19 | FROM all_tab_privs a 20 | WHERE a.grantee = UPPER('&1') 21 | AND a.privilege = 'SELECT' 22 | AND a.table_name = u.object_name); 23 | 24 | SPOOL OFF 25 | 26 | -- Comment out following line to prevent immediate run 27 | @temp.sql 28 | 29 | SET PAGESIZE 14 30 | SET FEEDBACK ON 31 | SET VERIFY ON 32 | -------------------------------------------------------------------------------- /security/grant_update.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/security/grant_update.sql 4 | -- Author : Tim Hall 5 | -- Description : Grants update on current schemas tables to the specified user/role. 6 | -- Call Syntax : @grant_update (schema-name) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'GRANT UPDATE ON "' || u.table_name || '" TO &1;' 16 | FROM user_tables u 17 | WHERE NOT EXISTS (SELECT '1' 18 | FROM all_tab_privs a 19 | WHERE a.grantee = UPPER('&1') 20 | AND a.privilege = 'UPDATE' 21 | AND a.table_name = u.table_name); 22 | 23 | SPOOL OFF 24 | 25 | -- Comment out following line to prevent immediate run 26 | @temp.sql 27 | 28 | SET PAGESIZE 14 29 | SET FEEDBACK ON 30 | SET VERIFY ON 31 | -------------------------------------------------------------------------------- /security/table_synonyms.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/security/table_synonyms.sql 4 | -- Author : Tim Hall 5 | -- Description : Creates synonyms in the current schema for all tables in the specified schema. 6 | -- Call Syntax : @table_synonyms (schema-name) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'CREATE SYNONYM "' || a.table_name || '" FOR "' || a.owner || '"."' || a.table_name || '";' 16 | FROM all_tables a 17 | WHERE NOT EXISTS (SELECT '1' 18 | FROM user_synonyms u 19 | WHERE u.synonym_name = a.table_name 20 | AND u.table_owner = UPPER('&1')) 21 | AND a.owner = UPPER('&1'); 22 | 23 | SPOOL OFF 24 | 25 | -- Comment out following line to prevent immediate run 26 | @temp.sql 27 | 28 | SET PAGESIZE 14 29 | SET FEEDBACK ON 30 | SET VERIFY ON 31 | -------------------------------------------------------------------------------- /security/view_synonyms.sql: -------------------------------------------------------------------------------- 1 | 2 | -- ----------------------------------------------------------------------------------- 3 | -- File Name : https://oracle-base.com/dba/security/view_synonyms.sql 4 | -- Author : Tim Hall 5 | -- Description : Creates synonyms in the current schema for all views in the specified schema. 6 | -- Call Syntax : @view_synonyms (schema-name) 7 | -- Last Modified: 28/01/2001 8 | -- ----------------------------------------------------------------------------------- 9 | SET PAGESIZE 0 10 | SET FEEDBACK OFF 11 | SET VERIFY OFF 12 | 13 | SPOOL temp.sql 14 | 15 | SELECT 'CREATE SYNONYM "' || a.view_name || '" FOR "' || a.owner || '"."' || a.view_name || '";' 16 | FROM all_views a 17 | WHERE a.owner = UPPER('&1') 18 | AND NOT EXISTS (SELECT '1' 19 | FROM user_synonyms u 20 | WHERE u.synonym_name = a.view_name 21 | AND u.table_owner = UPPER('&1')); 22 | 23 | SPOOL OFF 24 | 25 | -- Comment out following line to prevent immediate run 26 | @temp.sql 27 | 28 | SET PAGESIZE 14 29 | SET FEEDBACK ON 30 | SET VERIFY ON 31 | -------------------------------------------------------------------------------- /weblogic/deploy_app.sh: -------------------------------------------------------------------------------- 1 | 2 | #!/bin/bash 3 | path=$1 4 | app=$2 5 | targetlist=$3 6 | 7 | export MW_HOME=/u01/app/oracle/middleware 8 | export DOMAIN_HOME=$MW_HOME/user_projects/domains/myDomain 9 | . $DOMAIN_HOME/bin/setDomainEnv.sh 10 | 11 | if [ "$app" != "" -a "$targetlist" = "" ]; then 12 | java weblogic.WLST ~/scripts/deploy_app.py -p $path -a $app 13 | elif [ "$app" != "" -a "$targetlist" != "" ] ; then 14 | java weblogic.WLST ~/scripts/deploy_app.py -p $path -a $app -t $targetlist 15 | else 16 | java weblogic.WLST ~/scripts/deploy_app.py -p $path 17 | fi 18 | -------------------------------------------------------------------------------- /weblogic/start-domain.sh: -------------------------------------------------------------------------------- 1 | 2 | # ----------------------------------------------------------------------------------- 3 | # File Name : https://oracle-base.com/dba/weblogic/start-domain.sh 4 | # Author : Tim Hall 5 | # Description : Starts a WebLogic domain and managed server. 6 | # Call Syntax : ./start-domain.sh 7 | # Last Modified: 15-JUN-2013 8 | # Notes : Amend DOMAIN_HOME and managed server name appropriately. 9 | # ----------------------------------------------------------------------------------- 10 | 11 | export MW_HOME=/u01/app/oracle/middleware 12 | export DOMAIN_HOME=$MW_HOME/user_projects/domains/clusterDomain 13 | 14 | echo "Starting AdminServer" 15 | nohup $DOMAIN_HOME/startWebLogic.sh > /dev/null 2>&1 & 16 | sleep 120 17 | 18 | echo "Starting clusterServer_1" 19 | nohup $DOMAIN_HOME/bin/startManagedWebLogic.sh clusterServer_1 > /dev/null 2>&1 & 20 | sleep 60 21 | 22 | echo "Done!" -------------------------------------------------------------------------------- /weblogic/start-node-manager.sh: -------------------------------------------------------------------------------- 1 | 2 | # ----------------------------------------------------------------------------------- 3 | # File Name : https://oracle-base.com/dba/weblogic/start-node-manager.sh 4 | # Author : Tim Hall 5 | # Description : Starts the WebLogic Node Manager 6 | # Call Syntax : ./start-node-manager.sh 7 | # Last Modified: 15-JUN-2013 8 | # ----------------------------------------------------------------------------------- 9 | 10 | export MW_HOME=/u01/app/oracle/middleware 11 | export WLS_HOME=$MW_HOME/wlserver_10.3 12 | 13 | echo "Starting Node Manger" 14 | nohup $WLS_HOME/server/bin/startNodeManager.sh > /dev/null 2>&1 & 15 | 16 | echo "Done!" 17 | -------------------------------------------------------------------------------- /weblogic/stop-domain.sh: -------------------------------------------------------------------------------- 1 | 2 | # ----------------------------------------------------------------------------------- 3 | # File Name : https://oracle-base.com/dba/weblogic/stop-domain.sh 4 | # Author : Tim Hall 5 | # Description : Stops a WebLogic domain and managed server. 6 | # Call Syntax : ./stop-domain.sh 7 | # Last Modified: 15-JUN-2013 8 | # Notes : Amend DOMAIN_HOME and managed server name appropriately. 9 | # ----------------------------------------------------------------------------------- 10 | 11 | export MW_HOME=/u01/app/oracle/middleware 12 | export DOMAIN_HOME=$MW_HOME/user_projects/domains/clusterDomain 13 | 14 | echo "Stopping clusterServer_1" 15 | $DOMAIN_HOME/bin/stopManagedWebLogic.sh clusterServer_1 16 | 17 | echo "Stopping AdminServer" 18 | $DOMAIN_HOME/bin/stopWebLogic.sh 19 | 20 | echo "Tidy up temp files" 21 | find $DOMAIN_HOME/servers -name "*.lok" -exec rm -f {} \; 22 | find $DOMAIN_HOME/servers -name "*.DAT" -exec rm -f {} \; 23 | 24 | echo "Done!" -------------------------------------------------------------------------------- /weblogic/stop-forms-reports.sh: -------------------------------------------------------------------------------- 1 | 2 | # ----------------------------------------------------------------------------------- 3 | # File Name : https://oracle-base.com/dba/weblogic/stop-forms-reports.sh 4 | # Author : Tim Hall 5 | # Description : Stop a WebLogic Forms and Reports Services installation. 6 | # Call Syntax : ./stop-forms-reports.sh 7 | # Last Modified: 15-JUN-2013 8 | # ----------------------------------------------------------------------------------- 9 | 10 | export MW_HOME=/u01/app/oracle/middleware 11 | export DOMAIN_HOME=$MW_HOME/user_projects/domains/ClassicDomain 12 | export FR_INST=$MW_HOME/asinst_1 13 | 14 | echo "Stop OPMN processes" 15 | $FR_INST/bin/opmnctl stopall 16 | 17 | echo "Stop WLS_FORMS" 18 | $DOMAIN_HOME/bin/stopManagedWebLogic.sh WLS_FORMS 19 | echo "Stop WLS_REPORTS" 20 | $DOMAIN_HOME/bin/stopManagedWebLogic.sh WLS_REPORTS 21 | 22 | echo "Stop AdminServer" 23 | $DOMAIN_HOME/bin/stopWebLogic.sh 24 | 25 | echo "Tidy up temp files" 26 | find $DOMAIN_HOME/servers -name "*.lok" -exec rm -f {} \; 27 | find $DOMAIN_HOME/servers -name "*.DAT" -exec rm -f {} \; 28 | 29 | echo "Done!" 30 | -------------------------------------------------------------------------------- /weblogic/stop-node-manager.sh: -------------------------------------------------------------------------------- 1 | 2 | # ----------------------------------------------------------------------------------- 3 | # File Name : https://oracle-base.com/dba/weblogic/stop-node-manager.sh 4 | # Author : Tim Hall 5 | # Description : Stops the WebLogic Node Manager by killing the processes. 6 | # Call Syntax : ./stop-node-manager.sh 7 | # Last Modified: 15-JUN-2013 8 | # ----------------------------------------------------------------------------------- 9 | 10 | echo "Stopping Node Manger" 11 | kill -9 `ps -ef | grep [N]odeManager | awk '{print $2}'` --------------------------------------------------------------------------------