Search notes:

DBA_HIST_ACTIVE_SESS_HISTORY: Query begin and end of sessions

The following query selects the begin and end of sessions that have at least one entry in dba_hist_active_sess_history.
Unfortunately, it seems not possible to select to OS user with the DBA_HIST views.
select
   to_char(min(ash.sample_time), 'dd hh24:mi:ss')    start_,
   to_char(max(ash.sample_time),    'hh24:mi:ss')    end_,
   min(ash.sample_id)                                min_id,
   max(ash.sample_id)                                max_id,
   nvl(ash.qc_session_id     , ash.session_id     )  ses_id,
   nvl(ash.qc_session_serial#, ash.session_serial#)  ses_ser,
   usr.username                                      user_name,
   vdb.name                                          db_name
from
   v$database                   vdb                                    join
   dba_hist_active_sess_history ash on vdb.dbid     = ash.dbid    left join
   dba_users                    usr on ash.user_id  = usr.user_id
where
   ash.sample_time >= sysdate - 1
group by
   nvl(ash.qc_session_id     , ash.session_id     ),
   nvl(ash.qc_session_serial#, ash.session_serial#),
   usr.username,
   vdb.name
order by
   start_ desc
;

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759991968, '216.73.216.133', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/installed/data-dictionary/hist/active_sess_history/begin-and-end-of-session(59): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78