Database Logoff Trigger SQL
create or replace trigger logoff_tri
before logoff on database
declare
logoff_sid varchar2(50);
logoff_datetime date :=sysdate;
begin
select sid into logoff_sid from v$mystat where rownum<2;
insert into session_event_history
select s.SID,s.SERIAL#,s.USERNAME,s.OSUSER,s.PADDR,s.PROCESS,s.LOGON_TIME,s.TYPE,se.EVENT,se.TOTAL_WAITS,se.TOTAL_TIMEOUTS,se.TIME_WAITED,se.AVERAGE_WAIT,se.MAX_WAIT,sysdate datetime
from v$session_event se,v$session s
where se.SID=s.SID and s.sid=(select distinct sid from v$mystat where rownum<2);
insert into sesstat_history
select se.USERNAME,se.OSUSER,se.SID,se.SERIAL#,se.PADDR,se.PROCESS,se.LOGON_TIME,sa.STATISTIC#,st.NAME,sa.VALUE,sysdate datetime from
v$sesstat sa,v$statname st,v$session se
where sa.STATISTIC#=st.STATISTIC# and sa.SID=se.SID and sa.VALUE<>0
and se.sid=(select distinct sid from v$mystat where rownum<2);
commit;
end;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24237320/viewspace-1781073/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 用 logoff trigger 保留每個 session 的效能資訊GoSession
- 用 logoff trigger 保留每個 session 的效能資訊(轉)GoSession
- OWI -- 用 logoff trigger 保留每個 session 的效能資訊GoSession
- sql triggerSQL
- Query to Check SP/Table/Trigger Exists in Database or notDatabase
- ORA-01031 CREATE TRIGGER ON DATABASEDatabase
- TRIGGER裡的動態SQLSQL
- logon on database記錄登入資訊的triggerGoDatabase
- PL/SQL 07 觸發器 triggerSQL觸發器
- 系統許可權ADMINISTER DATABASE TRIGGER的作用Database
- SQL Database for Modern DevelopersSQLDatabaseDeveloper
- SQL Database Maintenance WizardSQLDatabaseAINaN
- indexedDB替代Web SQL Database原因IndexWebSQLDatabase
- T-SQL Verify Database BackupSQLDatabase
- Moving the tempdb database(SQL server)DatabaseSQLServer
- SQL指令碼建立trigger,owner用變數出錯。SQL指令碼變數
- Oracle SQL performance with database links - dblinkOracleSQLORMDatabase
- How to prevent blocking in your SQL Server databaseBloCSQLServerDatabase
- Mysql TriggerMySql
- jQuery trigger()jQuery
- ±±oracle trigger±±Oracle
- 使用after create 建立trigger記錄procedure PL/SQL程式碼變更SQL
- Azure SQL Database Active Geo-Replication 簡介SQLDatabase
- SQL SERVER – Attach mdf file without ldf file in DatabaseSQLServerDatabase
- SQL*Plus Enhancements in Oracle Database 10g(一)SQLOracleDatabase
- SQL SERVER BACKUP DATABASE 加快備份速度方法SQLServerDatabase
- Test Oracle triggerOracle
- Automatic SQL Tuning in Oracle Database 11gSQLOracleDatabase
- Oracle12c中多宿主環境(CDB&PDB)的資料庫觸發器(Database Trigger)Oracle資料庫觸發器Database
- Oracle trigger問題Oracle
- [AlwaysOn] 建立SQL Server高可用性組T-SQL語法:DATABASE子句SQLServerDatabase
- SQL Server database mail問題診斷一例SQLServerDatabaseAI
- 好書推薦—《精通Oracle Database 12c SQL&PL/SQL程式設計》OracleDatabaseSQL程式設計
- SqlServer 2005 TriggerSQLServer
- python trigger 組合Python
- COMPOUND TRIGGER學習
- logon_triggerGo
- oracle trigger 同步資料Oracle