Bo's Oracle Station

查看: 2671|回复: 0

(52-26)第44次:2016-02-02星期二

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2016-2-3 11:03:22 | 显示全部楼层 |阅读模式
本帖最后由 botang 于 2016-2-3 11:06 编辑

(52-26)上完1Z0-052第11章

2016-02-02fga.sql:
  1. select  * from dba_audit_trail  t  
  2. where t.username  not in ('SYSMAN','DBSNMP')
  3. order by t.timestamp   desc  ;

  4. select  * from dba_obj_audit_opts;

  5. select  * from dba_priv_audit_opts p order by p.privilege;

  6. select  * from dba_stmt_audit_opts;

  7. audit select any table by hr ;

  8. grant select any table to hr ;

  9. alter user sh identified by oracle_4U account unlock;

  10. grant select any table to sh ;

  11. noaudit select any table by hr;

  12. audit select any table by access;

  13. noaudit select any table;

  14. noaudit drop any table;

  15. audit drop any table by hr by access;

  16. create table hr.t05211_hr( a  number ) ;

  17. insert into hr.t05211_hr values (1) ;

  18. commit;

  19. create table sh.t05211_sh( a number ) ;

  20. insert into sh.t05211_sh values(1);

  21. commit;

  22. grant drop any table to hr;
  23. ---
  24.   select  * from dba_stmt_audit_opts
  25.   minus
  26.   select  * from dba_priv_audit_opts  ;
  27. ---
  28. audit table by hr ;

  29. ----

  30. select * from dba_policies; FGAC

  31. select  *  from dba_audit_policies  ;FGA

  32. ---

  33. create table tfga( a  varchar2(200))  ;

  34. alter table tfga modify ( a varchar2(2000));

  35. create or replace procedure procfga(p_schema varchar2,
  36.                                                           p_table varchar2,
  37.                                                           p_policy varchar2)
  38.   is
  39.   begin
  40.      insert into   tfga values('The user '||sys_context('userenv', 'session_user')||' (OS username is '||
  41.                                 sys_context('userenv', 'os_user')||' )'||sys_context('userenv', 'authentication_type')||
  42.                                 ' at time '||to_char(sysdate,'YYYY-MM-DD:HH24:MI:SS')||
  43.                                 ' at ip address '||sys_context('userenv', 'ip_address')||' had bad operation on '||p_schema||'.'||
  44.                                 p_table||'.'||'Policy is '||p_policy||'.'   );
  45.    end;                                          
  46.                                                          
  47. select  * from user_errors;

  48. select  * from user_objects o where o.object_name='PROCFGA';

  49. begin
  50.     dbms_fga.add_policy(object_schema => 'HR',
  51.     object_name => 'EMPLOYEES',
  52.     policy_name => 'POLICY1',
  53.     audit_condition => 'department_id=20',
  54.     audit_column => 'salary,commission_pct',
  55.     handler_schema => 'SYS',
  56.     handler_module => 'PROCFGA',statement_types => 'SELECT,UPDATE',
  57.     audit_trail => dbms_fga.DB+dbms_fga.EXTENDED,
  58.     audit_column_opts =>dbms_fga.ALL_COLUMNS);
  59.   end;
  60.    
  61.   ---
  62.   select  * from dba_fga_audit_trail t
  63. order by t.timestamp   desc  ;
  64.   
  65. select  * from tfga;
  66.    
  67.    
  68.    
  69.    





复制代码




2016-02-02value.sql:

  1. create or replace trigger hr.trg1
  2. after update of a on hr.t05211_check
  3. referencing new as new old as old
  4. for each row
  5. begin
  6.      if :old.a >= :new.a
  7.      then
  8.          raise_application_error(-20901,'Must be bigger.');
  9.       end if;
  10.   end;
  11.   
  12.   
  13.   select  * from dba_triggers  t where t.owner='HR' and t.trigger_name='TRG1';
  14.   
  15.   ---
  16.   
  17.   create table tvalue( a  varchar2(2000))  ;
  18.   
  19.   
  20.   create or replace trigger  trgvalue
  21.   after update of salary on  hr.employees
  22.   referencing new as new old as old
  23.   for each row
  24.   begin      
  25.      if :old.salary <> :new.salary
  26.      then
  27.       insert into   tvalue values('The user '||sys_context('userenv', 'session_user')||' The current user '||
  28.                      sys_context('userenv', 'current_user')||' (OS username is '||
  29.                                 sys_context('userenv', 'os_user')||' )'||sys_context('userenv', 'authentication_type')||
  30.                                 ' at time '||to_char(sysdate,'YYYY-MM-DD:HH24:MI:SS')||
  31.                                 ' at ip address '||sys_context('userenv', 'ip_address')||' had bad operation on '||:new.salary||'.'
  32.                                 ||:old.salary  );
  33.        end if;
  34.    end;           
  35.   
  36.    select  * from dba_triggers  t where t.owner='SYS' and t.trigger_name='TRGVALUE';
  37.    
  38.    select  * from tvalue;
  39.   
  40.   
  41.   
复制代码

direct.sql:
  1. create tablespace tbs05217 datafile '/home/oracle/tbs05217.dbf' size 6G;

  2. alter table hr.tc move tablespace tbs05217;

  3. select  s.segment_name  , s.bytes/1024/1024
  4. from dba_segments s
  5. where s.segment_name  in ('TC','TD') ;
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-3-29 00:00 , Processed in 0.044195 second(s), 81 queries .

快速回复 返回顶部 返回列表