可以的.oracle的功能很强大,包括creat等语句都能检测.

解决方案 »

  1.   


    你可以在数据库中建一个日志表,里面有登入用户名, 登入program ,ip , pc机器名 , 登入时间
    再建一个触发器
    create or replace trigger SYS.login_on_info -- 紀錄登入信息的觸發器
    after logon on database 
    Begin 
        insert into dbsys.login_log(session_id,login_on_time,login_off_time,user_in_db,machine,ip_address,run_program)
        select AUDSID,sysdate,null,sys.login_user,machine,SYS_CONTEXT('USERENV','IP_ADDRESS'),program
        from v$session where AUDSID = USERENV('SESSIONID');  --当前SESSION
    END;
    再建立一个触发器
    create or replace trigger SYS.drop_info 
    after drop on dbsys.schema  -- 在mfg0513user用戶上創建審計drop的觸發器
    begin 
        insert into drop_log
         (session_id,
         drop_time,
         ip_address,
         object_owner,
         object_name,
         object_type,
         drop_by_user)
         values(USERENV('SESSIONID'),
         sysdate,
         SYS_CONTEXT('USERENV','IP_ADDRESS'),
         sys.dictionary_obj_owner,
         sys.dictionary_obj_name,
         sys.dictionary_obj_type,
         sys.login_user);    
    end;这是记录DROP表,其它如CREATE和ALTER可以参与上面的写,对于DELETE、UPDATE、INSERT只能在表上写了!
    sql语句可以从V$SQL视图中找
      

  2.   

    create table login_log -- 登入注销信息表
    (
        session_id int not null, -- sessionid
        login_on_time  date, -- 登入时间
        login_off_time  date, -- 注销时间
        user_in_db varchar2(30), -- 登入的db user
        machine    varchar2(20),    -- 机器名
        ip_address varchar2(20), -- ip地址
        run_program varchar2(20)    -- 以何程序登入
    );create table allow_user -- 网域用户表
    (
        ip_address varchar2(20), -- ip地址
        login_user_name nvarchar2(20)   -- 操作者姓名
    );create or replace trigger login_on_info -- 纪录登入信息的触发器
    after logon on database 
    Begin 
        insert into login_log(session_id,login_on_time,login_off_time,user_in_db,machine,ip_address,run_program)
        select AUDSID,sysdate,null,sys.login_user,machine,SYS_CONTEXT('USERENV','IP_ADDRESS'),program
        from v$session where AUDSID = USERENV('SESSIONID');  --当前SESSION
    END;create or replace trigger login_off_info -- 纪录注销信息的触发器
    before logoff on database 
    Begin
    update login_log set  login_off_time = sysdate
    where session_id = USERENV('SESSIONID'); --当前SESSION
    exception
        when others then
         null;
    END;select l.ip_address,
    login_user_name,
    machine,
    run_program,
    to_char(login_on_time,'yyyy-mm-dd hh24:mi:ss') 
    from login_log l,allow_user a
    where l.ip_address=a.ip_address(+) 
    order by login_on_time;