--Create a folder where the path is the alter log pathCreate or ReplaceDirectory Data_dir as'/u01/app/oracle/diag/rdbms/orcl/orcl/trace';--Create an external tableCreate TableAlert_log (Text_linevarchar2(225)) organization external (TYPE Oracle_loaderDEFAULTDIRECTORY data_dir ACCESS PARAMETERS (RECORDS delimited byNEWLINE Fields) Location ('Alert_orcl.log' ));--Querying database startup time SQLSelectTo_char (Last_time)shutdown, To_char (start_time) Starup,round((start_time-Last_time)* - * -,2) Mins_down,round((Last_time-Lag (start_time) Over(Order byR)),2) days_up, Case when(Lead (R) Over(Order byR is NULL) Then round((sysdate-Start_time),2) Enddays_still_up from(SelectR, To_date (Last_time,'Dy Mon DD HH24:MI:SS YYYY', 'nls_date_language = American') Last_time, To_date (Start_time,'Dy Mon DD HH24:MI:SS YYYY', 'nls_date_language = American') Start_time from(SelectR, Text_line, Lag (Text_line,1) Over(Order byr) start_time, Lag (Text_line,2) Over(Order byr) Last_time from(Selectrownum R, Text_line fromAlert_logwhereText_line like '___ ___ __ __:__:__ 20__' orText_line like 'starting ORACLE instance%')) whereText_line like 'starting ORACLE instance%');
Oracle External table Check alter log