SlideShare a Scribd company logo
1 of 2
1) Create table : LOGON_LOGS
CREATE TABLE SYS.LOGON_LOGS
(
V_SYSDATE
DATE,
V_PROGRAM
VARCHAR2(128 BYTE),
V_MODULE
VARCHAR2(128 BYTE),
V_USERNAME VARCHAR2(128 BYTE),
V_MACHINE
VARCHAR2(128 BYTE),
V_OSUSER
VARCHAR2(128 BYTE)
)
TABLESPACE SYSTEM
RESULT_CACHE (MODE DEFAULT)
NOPARALLEL
/
2.Create Trigger DDL_TRIGGER
CREATE OR REPLACE TRIGGER SYS.DDL_TRIGGER
AFTER DDL
ON DATABASE
DISABLE
DECLARE
sql_text
ora_name_list_t;
stmt
CLOB;
n
NUMBER;
v_terminal
VARCHAR2 (30);
v_action
VARCHAR2 (30);
v_applyflag
VARCHAR2 (1);
BEGIN
SELECT action
INTO v_action
FROM v$session
WHERE sid = (SELECT DISTINCT sid FROM v$mystat);
IF v_action = 'NOLOG'
THEN
v_applyflag := 'X';
ELSE
v_applyflag := '0';
END IF;
SELECT SYS_CONTEXT ('USERENV', 'TERMINAL') INTO v_terminal FROM DUAL;
IF

ora_dict_obj_type IN
('FUNCTION',
'PROCEDURE',
'PACKAGE',
'PACKAGE BODY',
'TRIGGER',
'JAVA CLASS',
'JAVA DATA',
'JAVA RESOURCE',
'JAVA SOURCE',
'LIBRARY')
AND ora_sysevent IN ('CREATE', 'ALTER')
THEN
stmt := NULL;
ELSE
n := ora_sql_txt (sql_text);
IF n > 1000
THEN
n := 1000;
END IF;
FOR i IN 1 .. n
LOOP
stmt := stmt || sql_text (i);
END LOOP;
END IF;
INSERT INTO ddl_log
VALUES (ora_database_name,
ora_login_user,
ora_dict_obj_name,
ora_dict_obj_type,
ora_sysevent,
SYSDATE,
stmt,
v_terminal,
v_applyflag,
ora_dict_obj_owner);
END;
/

More Related Content

What's hot

Solr integration in Magento Enterprise
Solr integration in Magento EnterpriseSolr integration in Magento Enterprise
Solr integration in Magento EnterpriseTobias Zander
 
Yy
YyYy
Yyyygh
 
Nouveau document texte
Nouveau document texteNouveau document texte
Nouveau document texteSai Ef
 
DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7chuvainc
 
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
[Pgday.Seoul 2021] 2. Porting Oracle UDF and OptimizationPgDay.Seoul
 
The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 64 of 189
The Ring programming language version 1.6 book - Part 64 of 189The Ring programming language version 1.6 book - Part 64 of 189
The Ring programming language version 1.6 book - Part 64 of 189Mahmoud Samir Fayed
 
リローダブルClojureアプリケーション
リローダブルClojureアプリケーションリローダブルClojureアプリケーション
リローダブルClojureアプリケーションKenji Nakamura
 
Drupal csu-open atriumname
Drupal csu-open atriumnameDrupal csu-open atriumname
Drupal csu-open atriumnameEmanuele Quinto
 
Zabbix LLD from a C Module by Jan-Piet Mens
Zabbix LLD from a C Module by Jan-Piet MensZabbix LLD from a C Module by Jan-Piet Mens
Zabbix LLD from a C Module by Jan-Piet MensNETWAYS
 

What's hot (20)

Rootkit internales
Rootkit internales Rootkit internales
Rootkit internales
 
ETM Server
ETM ServerETM Server
ETM Server
 
Solr integration in Magento Enterprise
Solr integration in Magento EnterpriseSolr integration in Magento Enterprise
Solr integration in Magento Enterprise
 
XML-RPC vs Psycopg2
XML-RPC vs Psycopg2XML-RPC vs Psycopg2
XML-RPC vs Psycopg2
 
Yy
YyYy
Yy
 
Nouveau document texte
Nouveau document texteNouveau document texte
Nouveau document texte
 
DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7
 
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
 
The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Nantes Jug - Java 7
Nantes Jug - Java 7Nantes Jug - Java 7
Nantes Jug - Java 7
 
The Ring programming language version 1.6 book - Part 64 of 189
The Ring programming language version 1.6 book - Part 64 of 189The Ring programming language version 1.6 book - Part 64 of 189
The Ring programming language version 1.6 book - Part 64 of 189
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
リローダブルClojureアプリケーション
リローダブルClojureアプリケーションリローダブルClojureアプリケーション
リローダブルClojureアプリケーション
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Drupal csu-open atriumname
Drupal csu-open atriumnameDrupal csu-open atriumname
Drupal csu-open atriumname
 
zinno
zinnozinno
zinno
 
Coding website
Coding websiteCoding website
Coding website
 
JavaScript patterns
JavaScript patternsJavaScript patterns
JavaScript patterns
 
Zabbix LLD from a C Module by Jan-Piet Mens
Zabbix LLD from a C Module by Jan-Piet MensZabbix LLD from a C Module by Jan-Piet Mens
Zabbix LLD from a C Module by Jan-Piet Mens
 

Similar to Afte DDL on Database PL/SQL Code

Oracle trigger
Oracle triggerOracle trigger
Oracle triggernasrul28
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...DroidConTLV
 
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
8 bit single cycle processor
8 bit single cycle processor8 bit single cycle processor
8 bit single cycle processorDhaval Kaneria
 
Oracle - Program with PL/SQL - Lession 17
Oracle - Program with PL/SQL - Lession 17Oracle - Program with PL/SQL - Lession 17
Oracle - Program with PL/SQL - Lession 17Thuan Nguyen
 
MySQL Stored Procedures: Building High Performance Web Applications
MySQL Stored Procedures: Building High Performance Web ApplicationsMySQL Stored Procedures: Building High Performance Web Applications
MySQL Stored Procedures: Building High Performance Web ApplicationsOSSCube
 
Sql server ___________session_20(ddl triggers)
Sql server  ___________session_20(ddl triggers)Sql server  ___________session_20(ddl triggers)
Sql server ___________session_20(ddl triggers)Ehtisham Ali
 
A New View of Database Views
A New View of Database ViewsA New View of Database Views
A New View of Database ViewsMichael Rosenblum
 
Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.Kuldeep Jain
 
COMUNICACION SERIAL DSPIC30F3014 Y MATLAB
COMUNICACION SERIAL DSPIC30F3014 Y MATLABCOMUNICACION SERIAL DSPIC30F3014 Y MATLAB
COMUNICACION SERIAL DSPIC30F3014 Y MATLABCarlos Buitron Quispe
 
망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15종인 전
 
Redux for ReactJS Programmers
Redux for ReactJS ProgrammersRedux for ReactJS Programmers
Redux for ReactJS ProgrammersDavid Rodenas
 

Similar to Afte DDL on Database PL/SQL Code (20)

Oracle trigger
Oracle triggerOracle trigger
Oracle trigger
 
Plsql
PlsqlPlsql
Plsql
 
DOODB_LAB.pptx
DOODB_LAB.pptxDOODB_LAB.pptx
DOODB_LAB.pptx
 
MySQL
MySQLMySQL
MySQL
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
 
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should Know
 
Unit 4
Unit 4Unit 4
Unit 4
 
8 bit single cycle processor
8 bit single cycle processor8 bit single cycle processor
8 bit single cycle processor
 
Oracle - Program with PL/SQL - Lession 17
Oracle - Program with PL/SQL - Lession 17Oracle - Program with PL/SQL - Lession 17
Oracle - Program with PL/SQL - Lession 17
 
MySQL Stored Procedures: Building High Performance Web Applications
MySQL Stored Procedures: Building High Performance Web ApplicationsMySQL Stored Procedures: Building High Performance Web Applications
MySQL Stored Procedures: Building High Performance Web Applications
 
Triggers and Stored Procedures
Triggers and Stored ProceduresTriggers and Stored Procedures
Triggers and Stored Procedures
 
Sql server ___________session_20(ddl triggers)
Sql server  ___________session_20(ddl triggers)Sql server  ___________session_20(ddl triggers)
Sql server ___________session_20(ddl triggers)
 
A New View of Database Views
A New View of Database ViewsA New View of Database Views
A New View of Database Views
 
Taller
TallerTaller
Taller
 
Cdc
CdcCdc
Cdc
 
MySQL Presentation
MySQL PresentationMySQL Presentation
MySQL Presentation
 
Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.
 
COMUNICACION SERIAL DSPIC30F3014 Y MATLAB
COMUNICACION SERIAL DSPIC30F3014 Y MATLABCOMUNICACION SERIAL DSPIC30F3014 Y MATLAB
COMUNICACION SERIAL DSPIC30F3014 Y MATLAB
 
망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15
 
Redux for ReactJS Programmers
Redux for ReactJS ProgrammersRedux for ReactJS Programmers
Redux for ReactJS Programmers
 

More from Anar Godjaev

Asm disk group migration from
Asm disk group migration from Asm disk group migration from
Asm disk group migration from Anar Godjaev
 
How to protect your sensitive data using oracle database vault / Creating and...
How to protect your sensitive data using oracle database vault / Creating and...How to protect your sensitive data using oracle database vault / Creating and...
How to protect your sensitive data using oracle database vault / Creating and...Anar Godjaev
 
how to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vaulthow to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vaultAnar Godjaev
 
Database Vault / Verinin Güvenliği
Database Vault /  Verinin GüvenliğiDatabase Vault /  Verinin Güvenliği
Database Vault / Verinin GüvenliğiAnar Godjaev
 
Oracle Golden Gate
Oracle Golden GateOracle Golden Gate
Oracle Golden GateAnar Godjaev
 
Oracle 10g Database Server Kurulum
Oracle 10g Database Server KurulumOracle 10g Database Server Kurulum
Oracle 10g Database Server KurulumAnar Godjaev
 
DataPump ile Single Parititon Export
DataPump ile Single Parititon ExportDataPump ile Single Parititon Export
DataPump ile Single Parititon ExportAnar Godjaev
 
Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇Anar Godjaev
 
Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇Anar Godjaev
 
Instance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını IncelemeInstance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını IncelemeAnar Godjaev
 
Conditional Control
Conditional ControlConditional Control
Conditional ControlAnar Godjaev
 
Audit Mekani̇zmasi
Audit Mekani̇zmasiAudit Mekani̇zmasi
Audit Mekani̇zmasiAnar Godjaev
 

More from Anar Godjaev (20)

Oracle GoldenGate
Oracle GoldenGateOracle GoldenGate
Oracle GoldenGate
 
Asm disk group migration from
Asm disk group migration from Asm disk group migration from
Asm disk group migration from
 
How to protect your sensitive data using oracle database vault / Creating and...
How to protect your sensitive data using oracle database vault / Creating and...How to protect your sensitive data using oracle database vault / Creating and...
How to protect your sensitive data using oracle database vault / Creating and...
 
how to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vaulthow to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vault
 
Database Vault / Verinin Güvenliği
Database Vault /  Verinin GüvenliğiDatabase Vault /  Verinin Güvenliği
Database Vault / Verinin Güvenliği
 
Oracle Golden Gate
Oracle Golden GateOracle Golden Gate
Oracle Golden Gate
 
Oracle 10g Database Server Kurulum
Oracle 10g Database Server KurulumOracle 10g Database Server Kurulum
Oracle 10g Database Server Kurulum
 
DataPump ile Single Parititon Export
DataPump ile Single Parititon ExportDataPump ile Single Parititon Export
DataPump ile Single Parititon Export
 
Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇
 
Contraints
ContraintsContraints
Contraints
 
Oracle SQL
Oracle SQLOracle SQL
Oracle SQL
 
Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇
 
Instance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını IncelemeInstance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını Inceleme
 
Conditional Control
Conditional ControlConditional Control
Conditional Control
 
PL/SQL Blocks
PL/SQL BlocksPL/SQL Blocks
PL/SQL Blocks
 
Wait Interface
Wait InterfaceWait Interface
Wait Interface
 
Audit Mekani̇zmasi
Audit Mekani̇zmasiAudit Mekani̇zmasi
Audit Mekani̇zmasi
 
Tuning SGA
Tuning SGATuning SGA
Tuning SGA
 
Parallel Server
Parallel ServerParallel Server
Parallel Server
 
Table Partitions
Table PartitionsTable Partitions
Table Partitions
 

Afte DDL on Database PL/SQL Code

  • 1. 1) Create table : LOGON_LOGS CREATE TABLE SYS.LOGON_LOGS ( V_SYSDATE DATE, V_PROGRAM VARCHAR2(128 BYTE), V_MODULE VARCHAR2(128 BYTE), V_USERNAME VARCHAR2(128 BYTE), V_MACHINE VARCHAR2(128 BYTE), V_OSUSER VARCHAR2(128 BYTE) ) TABLESPACE SYSTEM RESULT_CACHE (MODE DEFAULT) NOPARALLEL / 2.Create Trigger DDL_TRIGGER CREATE OR REPLACE TRIGGER SYS.DDL_TRIGGER AFTER DDL ON DATABASE DISABLE DECLARE sql_text ora_name_list_t; stmt CLOB; n NUMBER; v_terminal VARCHAR2 (30); v_action VARCHAR2 (30); v_applyflag VARCHAR2 (1); BEGIN SELECT action INTO v_action FROM v$session WHERE sid = (SELECT DISTINCT sid FROM v$mystat); IF v_action = 'NOLOG' THEN v_applyflag := 'X'; ELSE v_applyflag := '0'; END IF; SELECT SYS_CONTEXT ('USERENV', 'TERMINAL') INTO v_terminal FROM DUAL; IF ora_dict_obj_type IN ('FUNCTION', 'PROCEDURE', 'PACKAGE', 'PACKAGE BODY', 'TRIGGER', 'JAVA CLASS', 'JAVA DATA', 'JAVA RESOURCE', 'JAVA SOURCE', 'LIBRARY') AND ora_sysevent IN ('CREATE', 'ALTER') THEN stmt := NULL; ELSE n := ora_sql_txt (sql_text); IF n > 1000 THEN
  • 2. n := 1000; END IF; FOR i IN 1 .. n LOOP stmt := stmt || sql_text (i); END LOOP; END IF; INSERT INTO ddl_log VALUES (ora_database_name, ora_login_user, ora_dict_obj_name, ora_dict_obj_type, ora_sysevent, SYSDATE, stmt, v_terminal, v_applyflag, ora_dict_obj_owner); END; /