DDL trigger

Hello

I tried DDL audit for help from under the sql statement,

Audit on schema.tablename by access;

This can be disabled by the No. AUDIT statement by the owner of the table.

Please suggest me if DDL trigger can be used, if so, please help me with the script to create the trigger so that the DDL statement issued by the owner of the table can be monitored and verified.


I don't know exactly why you need, but here is an example of code to audit the DDL from a particular table

------------

-Table to contain the audit entries

create the table aud_log_btopg

(

VARCHAR2 (50) of the event.

object_name varchar (1000).

object_type varchar2 (50).

action_date varchar2 (50).

machine to varchar2 (50).

program varchar2 (50).

OSUSER varchar2 (50).

dbuser varchar2 (50).

sql_text varchar2 (1000)

)

/

-Trigger to insert audit logging information in the table above

create or replace trigger aud_ddl_btopg
after create or alter or drop on &SCHEMA
declare
  v_num NUMBER;
  sql_stmt varchar2(2000);
  sql_text ora_name_list_t;
  l_sysevent varchar2(50);
  l_obj_name varchar2(50);
  l_obj_type varchar2(50);
  l_machine varchar2(50);
  l_prog varchar2(50);
  l_osuser varchar2(50);
  l_username varchar2(50);
  l_date varchar2(100);
begin
  -- if object of interest
  if ora_dict_obj_name = '&YOUR_TABLE' THEN
  -- get SQL executed
  v_num := ora_sql_txt(sql_text);
  FOR i in 1..NVL(v_num,0) LOOP
  sql_stmt:=sql_stmt||sql_text(i);
  END LOOP; 
  -- get the rest of the audit information
  select ora_sysevent,ora_dict_obj_name,ora_dict_obj_type,
  to_char(sysdate,'fm dd/Mon/yyyy HH:MI:SS AM'),
  machine,program,osuser,username into l_sysevent,l_obj_name,l_obj_type,l_date,l_machine,l_prog,l_osuser,l_username
  from v$session
  where audsid = sys_context( 'userenv', 'sessionid' ); 
  -- insert into audit table
  insert into aud_log_btopg values (l_sysevent,l_obj_name,l_obj_type,l_date,l_machine,l_prog,l_osuser,l_username,sql_stmt); 
  if ( sql%rowcount <> 1 )
  then
  raise_application_error
  ( -20001, 'Unable to id your session' );
  end if; 
  end if;
end;
/

----

I would not recommend the use of this type of audit in the production databases. Do not try to reinvent the wheel and use that provides the database.

Rgds,

IonutC

Tags: Database

Similar Questions

  • The DDL extract fail with ORA-30511: invalid operation of DDL TRIGGER system

    Hello

    When I tried to do all DDL operation I can see the following trace in ggs_ddl_trace.log with the trace level 2.
    It does not insert record in the GGS_DDL_HIST table.
    everything seems only when ddl_status.sql has been run...
    DDL replication is not the case.
    Help, please.

    SESS 30445-2012-04-12 11:16:09: DDL: start YVERT found [1147628]
    SESS 30445-2012-04-12 11:16:09: DDL: object ID is [74635]
    SESS 30445-2012-04-12 11:16:09: DDLTRACE1: before: point in execution = [4]
    SESS 30445-2012-04-12 11:16:09: DDLTRACE1: insertToMarker: inString =]
    SESS 30445-2012-04-12 11:16:09: DDLTRACE1:
    [SESS 30445-2012-04-12 11:16:09: DDLTRACE1:], type = target [0] = [1]
    SESS 30445-2012-04-12 11:16:09: DDLTRACE2: insertToMarker: optype marker = [0], current_fragment = [0]
    SESS 30445-2012-04-12 11:16:09: DDLTRACE2: insertToMarker: added the fragment part * 1 *]
    SESS 30445-2012-04-12 11:16:09: DDLTRACE2:
    [[SESS 30445-2012-04-12 11:16:09: DDLTRACE2:], new current fragment [], new length of it]
    SESS 30445-2012-04-12 11:16:09: DDLTRACE1: itemHeader: MD_TAB_DDLSTATEMENT (key1 = key2 [] = []) = [change the 'GGUSER' table. ["' Adds YASEEN" (column2 VARCHAR2 (30))], itemMode = [0]
    SESS 30445-2012-04-12 11:16:09: DDLTRACE2: escape_string: retVal = ['alter table 'GGUSER'.] ["" YASEEN ' add\ (VARCHAR2\ (30\)------) of Column2 ']
    SESS 30445-2012-04-12 11:16:09: DDLTRACE2: itemHeader: retVal = [, G1 =' alter table 'GGUSER'.] ["" YASEEN ' add\ (VARCHAR2\ (30\)------) of Column2 ',]
    SESS 30445-2012-04-12 11:16:09: DDLTRACE1: insertToMarker: inString =]
    SESS 30445-2012-04-12 11:16:09: DDLTRACE1:, G1 =' alter table 'GGUSER '. "" YASEEN ' add\ (column2 VARCHAR2\ (30\)------) ',
    [SESS 30445-2012-04-12 11:16:09: DDLTRACE1:], type = target [4] = [1]
    SESS 30445-2012-04-12 11:16:09: DDLTRACE2: insertToMarker: optype marker = [4], current_fragment = [0]
    SESS 30445-2012-04-12 11:16:09: DDLTRACE2: insertToMarker: added the fragment part * 2 *]
    SESS 30445-2012-04-12 11:16:09: DDLTRACE2:, G1 =' alter table 'GGUSER '. "" YASEEN ' add\ (column2 VARCHAR2\ (30\)------) ',
    [SESS 30445-2012-04-12 11:16:09: DDLTRACE2:], new ongoing fragment [, G1 =' alter table 'GGUSER'.] ["" YASEEN ' add\ (VARCHAR2\ (30\)------) of Column2 ',], new length of it [66]
    [SESS 30445-2012-04-12 11:16:09: DDLTRACE1: insertToMarker: total_fragments =]
    SESS 30445-2012-04-12 11:16:09: DDLTRACE1: insertToMarker: total_fragments (in a loop) = [1]
    SESS 30445-2012-04-12 11:16:09: DDLTRACE1: insertToMarker: fragment # = [1] fragment = [, G1 =' alter table 'GGUSER'.] ["" YASEEN ' add\ (VARCHAR2\ (30\)------) of Column2 ',]
    SESS 30445-2012-04-12 11:16:09: DDLTRACE1: insertToMarker: insertion in the history, objid [74635]
    SESS 30445-2012-04-12 11:16:09: DDL: insertToMarker: ORA-30511: invalid DDL operation in the system triggers
    SESS 30445-2012-04-12 11:16:09: DDL: getTableInfo: ORA-30511: invalid DDL operation in the system triggers
    * SESS 30445-2012-04-12 11:16:09: DDL: trigger sys. GGS_DDL_TRIGGER_BEFORE: processing error DDL operation [change the 'GGUSER' table. ["' Adds to the YASEEN" (VARCHAR2 (30)) Column2], error ORA-30511: invalid DDL operation in the system triggers, stack error: ORA-06512: at 'GGUSER '. DDLREPLICATION', line 2486 *.
    ORA-06512: at line 833 level

    SESS 30445-2012-04-12 11:16:09: DDL: cleaning sequence marker [17]
    SESS 30445-2012-04-12 11:16:09: DDL: cleaned [2] marker table rows
    SESS 30445-2012-04-12 11:16:09: DDL: cleaning sequence DDL [17]
    SESS 30445-2012-04-12 11:16:09: DDL: cleaned [0] lines of the DDL table

    Hello

    The recyclebin database is empty. Otherwise please purge the recyclebin and then try to make the changes.

    Thank you
    Kamal.

  • Getting the IP using a DDL trigger

    I created a DDL trigger that is triggered AFTER the DDL on SCHEMA.
    The unique attribute that seems to not work is the ORA_CLIENT_IP_ADDRESS
    If I try to create the following:

    CREATE OR REPLACE TRIGGER control_ddl
    AFTER the DDL ON SCHEMA
    BEGIN
    RAISE_APPLICATION_ERROR (-20000, 'Id' |) ORA_CLIENT_IP_ADDRESS | "conducted a DDL");
    END;

    and then I try to create a table, I get:

    ID made a DDL

    Could the reason because I do not have the ip address? A problem of grant? A network configuration issue? What else?
    I would like to get the IP address of the PC a person has made the DOF since and not the connection (by using the ORA_LOGIN_USER attribute), because all my colleagues use the same login to access DB
    Thank you!

    This construction in funciton gives the ip address of the machine, you can save it into a varchar2 variable and use it in your trigger.

    select sys_context('USERENV','IP_ADDRESS') from dual;
    
  • Please indicate how to generate the DDL trigger by using the Server Explorer view

    I can't find the place to click to generate the DDL for the triggers. Nor can I see where are my triggers. Is this supported?

    Hello

    Right click on the table that you want to trigger, click Add trigger. Expand the nodes under the table and you'll find triggers here.

    It will be useful,
    Greg

  • DDL trigger not pulling when executing other ddl schema.

    While learning to a review of the oracle and try a few things on my test database, I came across something strange.
    I have in my database, smithj and erik of Figure 2.

    While signed in as erik, I created this trigger:

    create or replace trigger drop_trigger
    before the fall on smithj. SCHEMA
    Start
    raise_application_error (-20000, 'NOT ALLOWED');
    end;

    and this table:

    create table smithj.test (kol1 varchar2 (10));

    When I connect you like smithj, then try to delete the table, the trigger is activated as expected:

    SQL error: ORA-00604: error occurred at the SQL level 1 recursive
    ORA-20000: UNAUTHORIZED

    Yet when I try to fall when I am logged in as erik that he succeeds:

    drop table smithj.test;

    table SMITHJ. TEST has fallen.

    I was wondering if someone could explain this behavior to me. I have a sort of expedted triggered when any user has tried to give up anything in the smithj schema.

    I have a sort of expedted triggered when any user has tried to give up anything in the smithj schema.

    Have a look here:
    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25519/triggers.htm#LNPLS99886

  • clarification of the trigger

    Hi all

    I use

    Connected to Oracle Database 11g Express Edition Release 11.2.0.2.0

    I use the Oracle HR schema

    I'm learning triggers

    This is my table script.

    CREATE TABLE EMPLOYEES_COPY

    AS

    SELECT * FROM EMPLOYEES

    CREATE TABLE EMPLOYEE_LOG)

    VARCHAR2 (30) WHO,.

    ON WHAT DATE).

    ALTER TABLE EMPLOYEE_LOG

    ADD (ACTION VARCHAR2 (2000))

    SQL > CREATE OR REPLACE TRIGGER AIUD_EMPLOYEES_COPY

    2 AFTER INSERT OR UPDATE OR DELETE

    3 ON EMPLOYEES_COPY

    4 DECLARE

    L_ACTION 5. EMPLOYEE_LOG % ACTION TYPE;

    L_SQLTEXT 6 ORA_NAME_LIST_T;

    7

    BEGIN 8

    9 INSERT THEN

    10 L_ACTION: = STATE_PACKAGE. ROWS_CHANGED | "AIRPLANES" | "INSERTED";

    11 ELSIF UPDATE THEN

    12 L_ACTION: = STATE_PACKAGE. ROWS_CHANGED | "AIRPLANES" | 'DAY '.

    13 ELSIF DELETION THEN

    14 L_ACTION: = STATE_PACKAGE. ROWS_CHANGED | "AIRPLANES" | 'DELETED ';

    15. OTHER

    16 RAISE_APPLICATION_ERROR ("-20001,' YOU SHOULD NEVER GET THIS ERROR");

    17 END IF;

    18

    INSERT INTO EMPLOYEE_LOG(WHO,ACTION,WHEN) VALUES (USER, L_ACTION, SYSDATE) 19.

    20

    21 L_ACTION: = ' THE STATEMENT THAT CAUSES THE CHANGE WAS:' | CHR (10);

    22

    23 FOR I IN 1.ORA_SQL_TXT (L_SQLTEXT)

    24 LOOP

    25 L_ACTION: = L_ACTION | L_SQLTEXT (I);

    26 END OF LOOP;

    27

    28 INSERT INTO EMPLOYEE_LOG(WHO,ACTION,WHEN) VALUES (USER, L_ACTION, SYSDATE);

    29 END;

    30.

    Trigger created

    Please help me understand the loop for

    I'm not able to understand computer

    Thank you

    It's everything nice and beautiful, just a little problem ORA_SQL_TXT is not available in the DML triggers:

    SQL > create table tbl (number n);

    Table created.

    SQL > CREATE OR REPLACE
    TRIGGER 2 TBL_BIR
    3 BEFORE INSERTING
    4 TBL
    5 FOR EACH LINE
    6 REPORT
    L_SQLTEXT 7 ORA_NAME_LIST_T;
    BEGIN 8
    9 FOR ME IN LOOP 1.ORA_SQL_TXT (L_SQLTEXT)
    10 DBMS_OUTPUT. PUT_LINE (L_SQLTEXT (I));
    11 END OF LOOP;
    12 END;
    13.

    Trigger created.

    SQL > SET SERVEROUTPUT ON
    SQL > INSERT
    2 TBL
    3 VALUES (5)
    4.
    IN TBL
    *
    ERROR on line 2:
    ORA-06502: PL/SQL: digital error or value
    ORA-06512: at "SCOTT. TBL_BIR', line 4
    ORA-04088: error during execution of trigger ' SCOTT. TBL_BIR'

    SQL >

    Why error? Like I said ORA_SQL_TXT is not available in the DML triggers so collection even ORA_SQL_TXT is not initialized:

    SQL > CREATE OR REPLACE
    TRIGGER 2 TBL_BIR
    3 BEFORE INSERTING
    4 TBL
    5 FOR EACH LINE
    6 REPORT
    L_SQLTEXT 7 ORA_NAME_LIST_T;
    BEGIN 8
    9 DBMS_OUTPUT. Put_line ('number of items in the collection is' |) NVL (TO_CHAR (ORA_SQL_TXT (L_SQLTEXT)), 'NULL'));
    10 END;
    11.

    Trigger created.

    SQL > INSERT
    2 TBL
    3 VALUES (5)
    4.
    Number of items in the collection is NULL

    1 line of creation.

    SQL >

    But if I create the DDL trigger:

    SQL > CREATE OR REPLACE
    TRIGGER 2 TBL_BALT
    3 BEFORE ALTER
    4 on SCOTT.schema
    5 REPORT
    L_SQLTEXT 6 ORA_NAME_LIST_T;
    7. START
    8 DBMS_OUTPUT. Put_line ('number of items in the collection is' |) NVL (TO_CHAR (ORA_SQL_TXT (L_SQLTEXT)), 'NULL'));
    9 FOR ME IN LOOP 1.ORA_SQL_TXT (L_SQLTEXT)
    10 DBMS_OUTPUT. PUT_LINE (L_SQLTEXT (I));
    11 END OF LOOP;
    12 END;
    13.

    Trigger created.

    SQL > alter table tbl
    2 Add the constraint tbl_pk
    3 key (n) elementary school
    4.
    Number of collection items is 1
    ALTER table tbl
    Add constraint tbl_pk
    key (n) elementary school

    Modified table.

    SQL >

    SY.

  • Errors when trying to add GG DDL suport

    Hello

    I'm trying to add support for the DDL in an Oracle database using GG Version 11.2.1.0.3 Linux 11.2.0.4.

    The marker configuration script work fine.

    But the ddl_enable.sql contains errors:

    SQL > ddl_setup.sql

    Configure Oracle GoldenGate DDL replication script

    Verify that the current user has privileges to install the DDL replication...

    You will be asked the name of a schema for Oracle GoldenGate database objects.
    NOTE: For a source of Oracle 10 g, the basket of the system must be disabled. For Oracle 11 g and later, it can be activated.
    NOTE: The schema must be created before running this script.
    NOTE: Stop all replication DDL before starting this installation.

    Enter the Oracle GoldenGate name schema: ogguser

    Working, please wait...
    Line to the ddl_setup_spool.txt file

    Checking the sessions that hold locks on the tables of metadata Oracle Golden Gate...

    Full version.

    Using OGGUSER as a name of schema Oracle GoldenGate.

    Working, please wait...

    Script of DDL replication configuration has completed, run the script to check...
    Please enter the name of a schema for GoldenGate database objects:
    Name of schema setting for OGGUSER

    CLEAR_TRACE STATUS:

    Error on line/pos
    ---------------------------------------- -----------------------------------------------------------------
    No error no error

    CREATE_TRACE STATUS:

    Error on line/pos
    ---------------------------------------- -----------------------------------------------------------------
    No error no error

    TRACE_PUT_LINE STATUS:

    Error on line/pos
    ---------------------------------------- -----------------------------------------------------------------
    No error no error

    INITIAL_SETUP STATUS:

    Error on line/pos
    ---------------------------------------- -----------------------------------------------------------------
    No error no error

    STATUS OF THE DDLVERSIONSPECIFIC PACKAGE:

    Error on line/pos
    ---------------------------------------- -----------------------------------------------------------------
    No error no error

    STATUS OF THE DDLREPLICATION PACKAGE:

    Error on line/pos
    ---------------------------------------- -----------------------------------------------------------------
    No error no error

    DDLREPLICATION STATE OF PACKAGE BODY:

    Error on line/pos
    ---------------------------------------- -----------------------------------------------------------------
    1878/17 PL/SQL: statement ignored
    1878/42 PL/SQL: ORA-00942: table or view does not exist
    2811/25 PL/SQL: statement ignored
    2811/50 PL/SQL: ORA-00942: table or view does not exist
    2850/29 PL/SQL: statement ignored
    2850/54 PL/SQL: ORA-00942: table or view does not exist
    3009/17 PL/SQL: statement ignored
    3009/42 PL/SQL: ORA-00942: table or view does not exist
    3040/29 PL/SQL: statement ignored
    3040/54 PL/SQL: ORA-00942: table or view does not exist
    3258/33 PL/SQL: statement ignored

    Error on line/pos
    ---------------------------------------- -----------------------------------------------------------------
    3258/58 PL/SQL: ORA-00942: table or view does not exist


    DDL IGNORE TABLE
    -----------------------------------
    Ok

    DDL IGNORED THE JOURNAL TABLE
    -----------------------------------
    Ok

    STATUS OF THE DDLAUX PACKAGE:

    Error on line/pos
    ---------------------------------------- -----------------------------------------------------------------
    No error no error

    DDLAUX STATE OF PACKAGE BODY:

    Error on line/pos
    ---------------------------------------- -----------------------------------------------------------------
    No error no error

    SYS. STATUS OF THE DDLCTXINFO PACKAGE:

    Error on line/pos
    ---------------------------------------- -----------------------------------------------------------------
    No error no error

    SYS. DDLCTXINFO STATE OF PACKAGE BODY:

    Error on line/pos
    ---------------------------------------- -----------------------------------------------------------------
    No error no error

    DDL HISTORY TABLE
    -----------------------------------
    FAILURE: The Table does not exist

    DDL HISTORY TABLE (1)
    -----------------------------------
    FAILURE: The Table does not exist

    DUMP DOF TABLES
    -----------------------------------
    FAILURE: The Table does not exist

    COLUMNS OF DUMP DDL
    -----------------------------------
    FAILURE: The Table does not exist

    GROUPS OF LOG DUMP DDL
    -----------------------------------
    FAILURE: The Table does not exist

    SCORES OF DUMP DDL
    -----------------------------------
    FAILURE: The Table does not exist

    DDL DUMP KEY PRIMARIES
    -----------------------------------
    FAILURE: The Table does not exist

    SEQUENCE OF the DDL
    -----------------------------------
    FAILURE: The sequence does not exist

    GGS_TEMP_COLS
    -----------------------------------
    Ok

    GGS_TEMP_UK
    -----------------------------------
    Ok

    STATE OF THE DDL TRIGGER CODE:

    Error on line/pos
    ---------------------------------------- -----------------------------------------------------------------
    133/25 PL/SQL: ORA-02289: sequence does not exist
    133/5 PL/SQL: statement ignored
    992/29 PL/SQL: ORA-00942: table or view does not exist
    992/4 PL/SQL: statement ignored


    DDL TRIGGER SYSTEM STATUS
    -----------------------------------
    Ok

    STATUS OF RACE DDL TRIGGER
    ------------------------------------------------------------------------------------------------------------------------
    ACTIVE

    STAYMETADATA TRIGGER
    ------------------------------------------------------------------------------------------------------------------------
    OFF

    TRACING OF SQL FOR DDL TRIGGER
    ------------------------------------------------------------------------------------------------------------------------
    0

    DDL TRIGGER TRACE LEVEL
    ------------------------------------------------------------------------------------------------------------------------
    0

    LOCATION OF THE TRACE OF DDL FILE
    ------------------------------------------------------------------------------------------------------------------------
    /U01/app/Oracle/diag/RDBMS/ogg11r2/ogg11r2/trace/ggs_ddl_trace.log

    Analyze the status of the installation...


    THE STATE OF REPLICATION DDL
    ------------------------------------------------------------------------------------------------------------------------
    ERRORS in the installation of software components of DDL replication (6)

    Complete script.

    Looking for the error of procedure of the STATE of DDLREPLICATION PACKAGE BODY:

    SQL > select line, text from user_source
    2 where name = 'DDLREPLICATION' and type = 'PACKAGE BODY' & line = line;
    Enter the value of line: 1878
    2 old: where name = 'DDLREPLICATION' and type = 'PACKAGE BODY' and line = & line
    2 new: where name = 'DDLREPLICATION' and type = 'PACKAGE BODY' and line = 1878

    LINE
    ----------
    TEXT
    --------------------------------------------------------------------------------
    1878
    INSERT INTO 'OGGUSER '. "" (GGS_DDL_HIST_ALT).

    This table does not exist and I don't see any script to GG home that even this table.

    The user ogg were created with this command:

    create ogguser user identified by BIENVENUE1
    default tablespace gold
    tablespace temporary temp;


    Grant connect, resource to ogguser.
    Grant select any dictionary, select any table of ogguser;
    grant create table ogguser;
    grant the flashback any table of ogguser;
    Grant execute on dbms_flashback to ogguser;
    Grant execute on utl_file to ogguser;
    grant create any table to ogguser;
    grant insert any table of ogguser;
    grant update any table to ogguser;
    Grant delete any table ogguser;
    grant drop any table of ogguser;
    grant dba to ogguser;
    EXEC DBMS_GOLDENGATE_AUTH. GRANT_ADMIN_PRIVILEGE ('OGGUSER');

    The trace file says:

    ESS 4294967295-2015-01-22 13:00:45: DDL: Initial installation from

    SESS 4294967295-2015-01-22 13:00:45: DOF: DOF create sequence: ORA-01031: insufficient privileges

    SESS 4294967295-2015-01-22 13:00:45: DDL: initial_setup: ORA-01031: insufficient privileges

    SESS 4294967295-2015-01-22 13:00:46: DDL: DEPARTURE OF DDL REPLICATION

    SESS 4294967295-2015-01-22 13:00:50: DDL: instantiating new DDL replication batch

    SESS 4294967295-2015-01-22 13:16: DDL: Initial installation from

    SESS 4294967295-2015-01-22 13:16: DOF: DOF create sequence: ORA-01031: insufficient privileges

    SESS 4294967295-2015-01-22 13:16: DDL: initial_setup: ORA-01031: insufficient privileges

    SESS 4294967295-2015-01-22 13:16: DDL: DEPARTURE OF DDL REPLICATION

    SESS 4294967295-2015-01-22 13:16:02: DDL: instantiating new DDL replication batch.

    No idea how to solve this problem?

    Thank you

    Arturo

    Hello

    Finally the problem is fixed with MOS:

    ORA-20782 creation GGS_DDL_RULES table; ORA-01031: insufficient Privs running DDL_setup.sql (Doc ID 1576164.1)

    And add this extra privs outside the DBA ROLE.

    grant create any table to ggs_app112;

    grant create any view of ggs_app112;

    grant create any ggs_app112 process;

    grant create any sequence of ggs_app112;

    grant create any index to ggs_app112;

    grant create any trigger to ggs_app112;

    grant create any view of ggs_app112;

    Thanks for the help.

    Concerning

    Arturo

  • How the DDL triggers AFTER CHANGE of work?

    I thought that this general framework for DDL triggers AFTER WHAT ALTER has been like that:

    -Implicit VALIDATION before the DDL statement (here: ALTER TABLE)

    -DDL statement

    -Implicit VALIDATION after DDL statement (here: ALTER TABLE)

    -AFTER ALTER DDL trigger fires

    And I also thought that everything is inside that trigger would be 'new' code as introduced by the ALTER TABLE DDL. But it looks like I'm missing something about this situation because the trigger next dbms_metadata.get_ddl procedure and seeing 'old' DDL code (before the ALTER TABLE statement).

    What Miss me? Could you give me some advice about this behavior? If I shouldn't expect returned DDL 'current' so why should I not?

    Thank you

    / * everything is done in the SCOTT schema * /.

    create table y (col1 varchar2 (5));

    create table t (dt date default sysdate, d varchar2 (4000));

    create or replace trigger trg

    After ON ALTER scott. SCHEMA

    declare

    v_d varchar2 (4000);

    Start

    Select cast (dbms_metadata.get_ddl ('TABLE', sys.dictionary_obj_name, sys.dictionary_obj_owner) as varchar2 (4000))

    in v_d

    Double;

    insert into t (d) values (v_d);

    end;

    ALTER table add col2 int;

    Select * from t; -This is the 'old' DOF with only col1

    I understand the transaction consistent reading, and it would work if second implicit validation had not been published before a trigger has been activated... the question is: is this second implicit validation has published in the above situation or I'm wrong about this, and commit the transaction started by first implicit included relaxation itself, and after he performed the second commit implicit came into play...

    It looks like this for me, but I have not found anything in the doc Oracle stating explicitly that this is the case... Could you confirm?

    Hmmm - I found it in the section client events of the doc PL/SQL language

    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28370/triggers.htm#g1722272

    The LOGON event starts a separate transaction and undertakes after firing the triggers. All the other events fire in the existing user transaction.

    Is the same with the AFTER DDL event where you thought to try this one.

    Why do you need the DOF immediately after it happens?

    Just capture the same and information of interest to a table. Then, later, asynchronously, run a job to get the DDL or everything that you need. The only "gotcha" If several ddl statements are issued against the table and you needed every one of them for some reason any. Not sure why you would need for each change.

  • How trigger if and object of the database will be created?

    Hi, how to write and trigger if any database object will be created? Concerning

    You can create a DDL trigger

    CREATE OR REPLACE TRIGGER trigger_name
      AFTER CREATE ON SCHEMA
    BEGIN
      <>
    END;
    

    Justin

  • audit the ddl

    Hello

    Suppose that I modified the table. for example I added the new column in the emp table. I would like to know the changes that had happened to specific table. Where can I get this information in the database?

    Someone of you can help me on this?

    Thanks in advance.

    You must either enable auditing on the tables you want to see, watch the doc for it:

    http://download.Oracle.com/docs/CD/B19306_01/network.102/b14266/auditing.htm#DBSEG125

    Alternatively, you can customize checking with a database DDL trigger and enter the information you want to see:

    http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14251/adfns_triggers.htm#ABC1032282

    Hope that helps.
    Paul

  • GRANT/REVOKE in system Trigger statement

    Hello

    I create DDL trigger and want to use the DCL statement in the trigger body. I wrote below bu trigger, it is invalid DDL operation s error in the outbreak.

    Could anyone suggest how we can use the under DCL statement in the trigger body.

    CREATE OR REPLACE TRIGGER trg_after_ddl
    AFTER the DDL ON SCHEMA
    BEGIN
    IF (ora_login_user = 'X') THEN
    IF (ora_database_name = ' XYZ.) WORLD ') THEN
    RUN IMMEDIATELY "REVOKE CREATE TABLE X;
    RUN IMMEDIATELY "REVOKE CREATE SEQUENCE X";
    END IF;
    END IF;
    END;
    /

    Thank you.
    Alok

    You cannot run all sorts of DDL statements in Oracle triggers because you cannot perform COMMIT / ROLLBACK in the triggers of the Oracle: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_triggers.htm#sthref1270

    Edited by: P. Forstmann on June 24, 2009 09:09

  • My Bugs addressed

    Hello

    Just back from vacation and downloaded the latest version of Oracle SQL Developer Data Modeler 4.1.1 and looked at the Bug list.

    While I realize that this is a short list, and while I had the chance to check out some of the issues that I addressed in this forum for the last 4 months, is there a complete list addressed problems/bugs that I could look at?  Or, how do I know if my question has been addressed in this version?

    Also, when the questions are saved as a bug, could we, as members of the community, be aware of the number of bug for our own tracking purposes.

    Best regards

    Ed Girard

    Hi Ed,

    Thank you for all your comments over the past months, and I understand your point that it would be useful to have the bug to your tracking numbers.

    I added a list below some of the bugs triggered in response to your comments which have been addressed in version 4.1.1:

    21096199 - ADD TABLE SCHEMA to AUTO INCREMENT SEQUENCE/TRIGGER NAME IN DOF if it is NECESSARY Auto increment sequence/DDL trigger question

    21084149 - CANNOT SCROLLING at the end of THE LIST IN THE OBJECTS NAMES ADMINISTRATION DIALOGUE the rule of naming feature can be overridden in some cases?

    21066943 FEATURE of MODIFICATION of the SCRIPT ENGINE IN CUSTOM LIBRARIES of NE what is the right way to install JRuby (jruby.jar)?


    21053323 - NOT NULL CONSTRAINT NAME PATTERN cannot NOT BE APPLIED standards of naming model does not (consistantly)


    David

  • Warning message before you rename a column

    Hi gurus,

    I need your suggestion. I am desiging a module to move data from one table to the schema of intermediate archives and then delete intermediate tables, such as each table has it's own rules to keep history (some of them need 2 weeks, 1 month etc) and deleting based on reporting_date for some tables, rpt_dt other reporting_dt other and so on... (inconsistent naming). Because most of the tables is not partitioned, I have to do in the conventional way of copying the data and then remove. (Speaking of ~ 100 tables, data to remove from 100K to 1 million)

    My plan is to create a table as follows, which highlights each table name and field based on which remove will

    Table of correspondence:

    KEYSOURCE_TABLEFIELDNAMESTARTEGYKEY
    1000T1REPORTING_DATE1
    2000T2RPT_DT1
    3000T3RPT_DT2

    Strategy table:

    STRATEGYKEYSTG_KEEP_DAYSCOMMENTS
    114Default option
    230Keep the last 30 days

    My question is I want to create an alert so that if a developer RENAMES the RPT_DT of the RPTDT column in table T2, it must either refuse the user until it changes the above new domain name mapping table entry. Otherwise refuse, at least draw the attention of the user. How do I get it? I was curious to know if there are new techniques in versions of oracle 10 g / 11 g (mine is 11 g) apart from old techniques I could think

    (1) create a level trigger statement for 100 + tables on the field of Reporting_dt/Reporting_date/RPT_Dt, such that the error is thrown in the exception block (this could slow down the load ETL). Difficult to maintain.

    (2) handle reactive IE perform a daily check to see if a field name in the mapping table exists in all_tables.

    I learned a lot of new techniques in this forum where many new features have been introduced by oracle, or others had a cleaner and better how to implement their experience practice.

    Thank you

    Sunny

    I do not understand how your statement-level trigger approach would work.  Rename a column is DOF, no DML, the ALTER TABLE that rename the column don't trigger a DML trigger.  Level trigger statement that try to validate the structure of the table to the data you're now would place a huge burden and would not raise an error up to this than potentially long after that the disturbing change has been made.

    I guess you can create a DDL trigger that took place when a user has changed the table who tried to validate the DDL against the data in the table (probably using ora_is_alter_column and ora_is_drop_column functions).  That could probably be put into work, but you should always remember to change the data in your table and then run DDL on your table, and not the reverse.

    A DML trigger on your mapping table that checks if the data in your mapping table corresponding to the table definition would be easier to write.  But you would be once again be capture potentially long errors after a rogue DDL statement was executed.

    You could get even more esoteric using something like water course to post the DDL changes and write a subscriber process may change your mapping table or triggered some kind of alert if there was a disconnect.  If you are the Subscriber for a little delay, you could give time for the LMD to the mapping table (most likely) would have completed to make coherent whole before validating the DDL.

    If you are looking for a technical solution, however, I will do as you no matter what time you want to make sure that coherent sets of changes are made - would create a stored procedure that combines some DOF and you want to allow and prevent people from having the possibility to issue direct DDL statements of the DML changes.  If your procedure is written correctly and is the only way to do this kind of manipulation, you should be able to track changes in sync (except for cases where the procedure was partially successful because engages in the DDL and mistakes elsewhere).

    In reality, however, this is not a technical problem if you probably don't want a technical solution.  Rename a column isn't something that would be never done willy nilly.  This is something that should be done as part of a change of control.  This change of control should be considered at least two beings who can catch stupid things.  That change control should be accompanied by tests that validate things like the ability of your process to ETL, data in the mapping table corresponds to the definition tables.  This change of control should be tested in environments below.  At the time wherever a change is ready to be deployed to production, you should be fairly confident roughly that the definition of the table will match the data in your mapping table.  A process-based solution would make me much more comfortable than a technical solution to this kind of question.

    Justin

  • Transformation of Scripts that run only on the selected Tables

    I'm relatively new to Data Modeler, but found almost everything to be very intuitive. I'm now doing use custom transformation scripts to dynamically add custom DDL elements. I wrote a transformation script that adds a sequence at the end of my DDL trigger successfully, and I'm happy with the results. The problem I run into is that we have two different categories of tables that require slightly different sequence triggers, but as my model is set to the level of database, my transformation scripts are applied to all arrays regardless they come what schema. Do you have any suggestions on how to limit the tables which proceeds by a transformation script? I thought to add if statements to check what schema tables are coming from, but if I have a situation where I have two different tables that require two different processing scripts, but they are in the same pattern, how can that I manage that? Ideally, I'd like to just pick a table and apply a transformation script for this table individually. Is this possible?

    I work in a relational model with Data Modeler 4.0.

    to dynamically add items customized to DDL

    you need to check the custom of DDL in DM 4.1 features - "tools > rules and design transformations > Table DDL transformations"-DM 4.1 comes with example to generate tables of the newspaper and associated trigger.

    . I wrote successfully in a transformation script that adds a sequence at the end of my DDL trigger

    Data Modeler can generate the sequence and relaxation for you - you need to define the column as 'auto increment' / identity and set in preferences, you want "trigger" put in place. 4.1 DM added support for z/OS, DB2 LUW DB2 and MS SQL Server 2012.

    Do you have any suggestions on how to limit the tables which proceeds by a transformation script? I thought to add if the instructions to check the schema, the tables are coming, but if I have a situation where I have two different tables that require two different processing scripts, but they are in the same schema

    Well you need to sort it out on yourself - you can use classification types, dynamic properties user defined properties (in DM 4.1) or put paintings in various subviews or use the search feature (4.0.3 DM / DM 4.1 comes for example how to use the search results to create subview).

    Ideally, I'd like to just pick a table and apply a transformation script for this table individually. Is this possible?

    Here is an example of how get selected tables:

    appv = model.getAppView();
    dpv = appv.getCurrentDPV();
    //check there is a diagram selected and it belongs to the same model
    if(dpv!=null && dpv.getDesignPart() == model){
     tvs = dpv.getSelectedTopViews();
     for(var i=0;i
    

    Philippe

  • When I run the "@ddl_setup.sql" on a node of the 11gr2rac getting errors

    I want to open DDL replicate of the source node, so I run

    SQL > @marker_setup

    Marker setup script

    You will be asked the name of a schema for Oracle GoldenGate database objects.

    NOTE: The schema must be created before running this script.

    NOTE: Stop all replication DDL before starting this installation.

    Enter the Oracle GoldenGate name schema: ogg

    Table marker installation script is completed, run the script to check...

    Please enter the name of a schema for GoldenGate database objects:

    Name of schema setting for OGG

    MARKER TABLE

    -------------------------------

    Ok

    SEQUENCE MARKER

    -------------------------------

    Ok

    When I run the "@ddl_setup.sql" on a node of the 11gr2rac getting errors

    SQL > @ddl_setup.sql

    Configure Oracle GoldenGate DDL replication script

    Verify that the current user has privileges to install the DDL replication...

    You will be asked the name of a schema for Oracle GoldenGate database objects.

    NOTE: For a source of Oracle 10 g, the basket of the system must be disabled. For Oracle 11 g and later, it can be activated.

    NOTE: The schema must be created before running this script.

    NOTE: Stop all replication DDL before starting this installation.

    Enter the Oracle GoldenGate name schema: ogg

    Working, please wait...

    Line to the ddl_setup_spool.txt file

    Checking the sessions that hold locks on the tables of metadata Oracle Golden Gate...

    Full version.

    Using OGG as Oracle GoldenGate scheme a name.

    Working, please wait...

    Script of DDL replication configuration has completed, run the script to check...

    Please enter the name of a schema for GoldenGate database objects:

    Name of schema setting for OGG

    CLEAR_TRACE STATUS:

    Error on line/pos

    -------------------- -----------------------------------------------------------------

    No error no error

    CREATE_TRACE STATUS:

    Error on line/pos

    -------------------- -----------------------------------------------------------------

    No error no error

    TRACE_PUT_LINE STATUS:

    Error on line/pos

    -------------------- -----------------------------------------------------------------

    No error no error

    INITIAL_SETUP STATUS:

    Error on line/pos

    -------------------- -----------------------------------------------------------------

    No error no error

    STATUS OF THE DDLVERSIONSPECIFIC PACKAGE:

    Error on line/pos

    -------------------- -----------------------------------------------------------------

    No error no error

    STATUS OF THE DDLREPLICATION PACKAGE:

    Error on line/pos

    -------------------- -----------------------------------------------------------------

    No error no error

    DDLREPLICATION STATE OF PACKAGE BODY:

    Error on line/pos

    -------------------- -----------------------------------------------------------------

    1453/9 PL/SQL: statement ignored

    1455/23 PL/SQL: ORA-00942: table or view does not exist

    1464/9 PL/SQL: statement ignored

    1466/23 PL/SQL: ORA-00942: table or view does not exist

    1478/9 PL/SQL: statement ignored

    1480/23 PL/SQL: ORA-00942: table or view does not exist

    1485/9 PL/SQL: statement ignored

    1487/23 PL/SQL: ORA-00942: table or view does not exist

    1492/9 PL/SQL: statement ignored

    1494/23 PL/SQL: ORA-00942: table or view does not exist

    1499/9 PL/SQL: statement ignored

    Error on line/pos

    -------------------- -----------------------------------------------------------------

    1501/23 PL/SQL: ORA-00942: table or view does not exist

    1581/4 PL/SQL: statement ignored

    1582/18-PL/SQL: ORA-00942: table or view does not exist

    1584/4 PL/SQL: statement ignored

    1585/18-PL/SQL: ORA-00942: table or view does not exist

    1600/25 PL/SQL: ORA-00942: table or view does not exist

    1600/4 PL/SQL: statement ignored

    1602/25 PL/SQL: ORA-00942: table or view does not exist

    1602/4 PL/SQL: statement ignored

    DDL IGNORE TABLE

    -----------------------------------

    FAILURE: The Table does not exist

    DDL IGNORED THE JOURNAL TABLE

    -----------------------------------

    FAILURE: The Table does not exist

    STATUS OF THE DDLAUX PACKAGE:

    Error on line/pos

    -------------------- -----------------------------------------------------------------

    No error no error

    DDLAUX STATE OF PACKAGE BODY:

    Error on line/pos

    -------------------- -----------------------------------------------------------------

    0/0 PL/SQL: analysis of completed Compilation unit

    1/21 PLS-00304: impossible to compile a body of 'DDLAUX' without sound

    specification of the

    1/21 PLS-00905: OGG object. DDLAUX is not valid

    SYS. STATUS OF THE DDLCTXINFO PACKAGE:

    Error on line/pos

    -------------------- -----------------------------------------------------------------

    No error no error

    SYS. DDLCTXINFO STATE OF PACKAGE BODY:

    Error on line/pos

    -------------------- -----------------------------------------------------------------

    No error no error

    DDL HISTORY TABLE

    -----------------------------------

    FAILURE: The Table does not exist

    DDL HISTORY TABLE (1)

    -----------------------------------

    FAILURE: The Table does not exist

    DUMP DOF TABLES

    -----------------------------------

    FAILURE: The Table does not exist

    COLUMNS OF DUMP DDL

    -----------------------------------

    FAILURE: The Table does not exist

    GROUPS OF LOG DUMP DDL

    -----------------------------------

    FAILURE: The Table does not exist

    SCORES OF DUMP DDL

    -----------------------------------

    FAILURE: The Table does not exist

    DDL DUMP KEY PRIMARIES

    -----------------------------------

    FAILURE: The Table does not exist

    SEQUENCE OF the DDL

    -----------------------------------

    FAILURE: The sequence does not exist

    GGS_TEMP_COLS

    -----------------------------------

    FAILURE: The Table does not exist

    GGS_TEMP_UK

    -----------------------------------

    FAILURE: The Table does not exist

    STATE OF THE DDL TRIGGER CODE:

    Error on line/pos

    -------------------- -----------------------------------------------------------------

    126/9 PL/SQL: statement ignored

    128/23 PL/SQL: ORA-00942: table or view does not exist

    133/21 PL/SQL: ORA-02289: sequence does not exist

    133/5 PL/SQL: statement ignored

    657/14 PLS-00905: OGG object. DDLAUX is not valid

    657/5 PL/SQL: statement ignored

    919/25 PL/SQL: ORA-00942: table or view does not exist

    919/4 PL/SQL: statement ignored

    DDL TRIGGER SYSTEM STATUS

    -----------------------------------

    Ok

    STATUS OF RACE DDL TRIGGER

    ----------------------------------------------------------------------

    ACTIVE

    OF "OGG". "" GGS_SETUP ".

    *

    ERROR on line 2:

    ORA-00942: table or view does not exist

    OF "OGG". "" GGS_SETUP ".

    *

    ERROR on line 2:

    ORA-00942: table or view does not exist

    OF "OGG". "" GGS_SETUP ".

    *

    ERROR on line 2:

    ORA-00942: table or view does not exist

    LOCATION OF THE TRACE OF DDL FILE

    ------------------------------------------------------------------------------------------------------------------------

    /Home/data/app/Oracle/diag/RDBMS/AppStore/appstore2/trace/ggs_ddl_trace.log

    Analyze the status of the installation...

    THE STATE OF REPLICATION DDL

    ------------------------------------------------------------------------------------------------------------------------

    ERRORS in the installation of software components of DDL replication (6)

    Complete script.

    I had been struggling with the same problem for 2 days. You run the script as sysdba, how do you get the error then insufficient? I did my first test GG in February. I've been on 11.2.0.3 + patch January + patch for the integrated capture. It has worked well for me. I went back to my GG test week with 11.2.0.3 + patch of July last and ran into the same problem. The solution for me was the last version of GG. See my previous post for the patch numbers.

    Post edited by: ursusca

Maybe you are looking for

  • Failed to load itunes application support app.

    At itunes, but he lost on my pc. Trying to recharge but asking to support the request. Help, please

  • HP ENVY 15 t-k200 CTO: "INCORRIGIBLE ERROR WHEA" on HP Envy

    A bit ago I was using my laptop HP Envy, as usual, just to watch a video on Youtube, when it crashed and I got a blue screen with the error 'WHEA_UNCORRECTABLE_ERROR '. My boyfriend suggested that maybe it was a driver that requires an update, so I w

  • Pavilion 500-314: graphics card for 500-314 Pavilion update

    Please suggest a graphics card for me. I have the R7 Radion integrated AMD provided with the motherboard, when I bought the Office a couple of years. Max resolution seems to be 1600 x 1200.  I want to improve my (two) monitors and the graphics card i

  • Hard drive Question on new Y50

    Hi, I ordered a Y50 last week and I'm waiting to be shipped. I've gone through these forums a lot try to seek answers to my question. I intend later my SSHD to a 512 GB or 1 TB SSD 1 TB upgrade when prices are met. What I'm confused about is a recove

  • Photo not showing in iTunes library

    I don't see any photo library inside iTunes-> phone-> photos.My complete collection of photos or any newly created test library can be selected in the option "copy photos since. I don't know if this question is related to the last update of macos 10.