Scripts for Oracle record user DDL operations

Source: Internet
Author: User
--Current ordinary user creates issgzt create table Tab_ddl (Login_user VARCHAR2, audsid number, MACH      INE VARCHAR2, IPAddress VARCHAR2, Schema_user VARCHAR2 (a), schema_object VARCHAR2, Ddl_time DATE, Ddl_sql VARCHAR2 (4000), MODULE VARCHAR2 (100)  
      
      
, Schema_object_type VARCHAR2 (60)); --sys user creation, monitoring user DDL Operations for Oracle Create OR REPLACE TRIGGER SYS.TR_ISSGZT_DDL after DDL on database DECLARE sql_text o  
  ra_name_list_t; State_sql Issgzt.  
  Tab_ddl.ddl_sql%type; V_program Issgzt.  
  Tab_ddl.module%type;  
      
Error1 exception; BEGIN IF SUBSTR (sys_context (' USERENV ', ' Session_user '), 1, 1) = ' T ' and Sys_context (' USERENV ', ' Session_user  
        
  ') not in (' username ') and lower (state_sql) don't like ' alter user t% ' THEN raise;  
      
  End If; For I in 1.
      NVL (Ora_sql_txt (Sql_text), 2) LOOP beginState_sql: = State_sql | |  
    Sql_text (i);  
    Exception when others then null;  
  End  
  End LOOP; Select NVL (S.program, s.module) into V_program to v$session s where S.sid = (select distinct SID from V  
      
  $MYSTAT); INSERT into Issgzt.  
     TAB_DDL (Login_user, Audsid, Machine, IPAddress, Schema_user, Schema_object, Schema_object_type, Ddl_time, Ddl_sql, module) VALUES (Ora_login_user, Userenv (' SES Sionid '), Sys_context (' USERENV ', ' TERMINAL '), Sys_context (' USERENV ', ' ip_address '), Ora_dict_obj_owne R, Ora_dict_obj_name, Ora_dict_obj_type, Sysdate, substr (state_sql, 1, 3000), V_program  
); EXCEPTION when Error1 THEN raise_application_error (num => -20000, msg =& Gt  
' ERROR ');  
End TR_TRACE_DDL; /

This column more highlights: http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.