28 April 2016

Check, how many times a database has been restarted

Can you find out how many times a database has been restarted since its creation?
Well, the answer is YES!

Oracle has this view dba_hist_database_instance for getting these details:

DBA_HIST_DATABASE_INSTANCE

DBA_HIST_DATABASE_INSTANCE displays the databases and instances in the Workload Repository.
ColumnDatatypeNULLDescription
DBIDNUMBERNOT NULLDatabase ID
INSTANCE_NUMBERNUMBERNOT NULLInstance number
STARTUP_TIMETIMESTAMP(3)NOT NULLStartup time of the instance
PARALLELVARCHAR2(3)NOT NULLIndicates whether the instance is running in an Oracle Real Application Clusters (Oracle RAC) environment (YES) or not (NO)
VERSIONVARCHAR2(17)NOT NULLDatabase version
DB_NAMEVARCHAR2(9) Name of the database
INSTANCE_NAMEVARCHAR2(16) Name of the instance
HOST_NAMEVARCHAR2(64) Name of the host
LAST_ASH_SAMPLE_IDNUMBERNOT NULLLast sample ID for the active session history


SELECT STARTUP_TIME FROM dba_hist_database_instance ORDER BY startup_time DESC;


Hope this was helpful, have an Oracle day!