zoukankan      html  css  js  c++  java
  • 17.08.10

    audit

     

    开启开关参数:

    SQL> show parameter audit_trail

    设置审计选项:

    每次设置新的审计选项,测试用户需要重新连接

    sys准备工作:

    SQL> drop user user01 cascade;

    SQL> create user user01 identified by password;

    SQL> grant create session, create table, create any table to user01;

    审计系统权限:

    SQL> AUDIT CREATE ANY TABLE, CREATE TABLE BY USER01 BY ACCESS;

    user01测试:

    SQL> create table t1(x int);

    SQL> create table t1(x int);              失败

    SQL> create table hr.t1(x int);

    SQL> create table hr.t1(x int);          失败

    sys查看审计结果:

    SQL> desc aud$

    SQL> desc dba_audit_trail

    浏览器中查看

    sys添加审计条件:

    SQL> AUDIT SELECT ANY TABLE BY user01 BY ACCESS;

    SQL> grant select any table to user01;

    user01测试:

    SQL> select * from t1;

    SQL> select * from hr.t1;

    sys查看审计结果:

    浏览器中或者查看dba_audit_trail表

    删除审计选项:

    SQL> NOAUDIT CREATE ANY TABLE BY USER01;

    SQL> NOAUDIT CREATE TABLE BY USER01;

    SQL> NOAUDIT SELECT ANY TABLE BY user01;

    审计对象:

    sys设置审计选项:

    SQL> AUDIT SELECT ON hr.employees BY ACCESS;

    SQL> drop user user01 cascade;

    SQL> create user user01 identified by password;

    SQL> grant create session to user01;

    sys授权,每执行一个语句,user01就测试一次:

    SQL> grant select any table to user01;

    SQL> revoke select any table from user01;

    SQL> grant select on hr.employees to user01;

    user01测试(执行4次):

    SQL> select count(*) from hr.employees;

    默认不记录sys的行为:

    SQL> select count(*) from hr.employees;

    删除审计选项:

    SQL> NOAUDIT SELECT ON hr.employees;

    审计语句:

    sys设置审计选项:

    SQL> AUDIT TABLE BY user01 BY ACCESS;

    user01测试:

    SQL> create table t1(x int);     失败

    SQL> create table t1(x int);

    SQL> create table t1(y int);     失败

    SQL> drop table t1;

    sys查看结果:

    浏览器中,或DBA_AUDIT_OBJECT表中

    删除审计选项:

    SQL> NOAUDIT TABLE BY USER01

    审计sys的操作:

    SQL> show parameter audit

    修改两个参数

    并发管理

    读写冲突通过读一致性解决:

    sys准备工作:

    SQL> create user user01 identified by password;

    SQL> grant dba to user01;

    以下都用user01:

    SQL> conn user01/password

    Connected.

    SQL> create table t1(x int);

    SQL> insert into t1 values (1);

    SQL> commit;

    session1:

    SQL> update t1 set x=11 where x=1;

    SQL> select * from t1;

    session 2:

    SQL> select * from t1;

    session 1:

    SQL> commit;

    session 2:

    SQL> select * from t1;

    测试serializable:

    session1:

    SQL> alter session set isolation_level=serializable;

    重复上面的步骤

    写与写的冲突通过锁机制解决:

    session 1:

    SQL> update t1 set x=11 where x=1;

    浏览器中查看锁信息

    session 2:

    SQL> update t1 set x=111 where x=1;             被阻塞

    浏览器中查看锁信息

    session 1:

    SQL> rollback;

    浏览器中查看锁信息

  • 相关阅读:
    Sql Server数据库快照初探
    RestTemplate的exchange()方法,解决put和delete请求拿不到返回值的问题
    常用 HTTP 状态码
    RestTemplate进行访问分页PageInfo
    Java RestTemplate传递参数
    SQL-----数据库三种删除方式详解
    Mybatis异常-java.lang.IllegalArgumentException: invalid comparison:java.util.Date and java.lang.String
    SpringBoot 项目不加载 application.properties 配置文件
    git设置、查看、取消代理
    Layui:select下拉框回显
  • 原文地址:https://www.cnblogs.com/Zhang-x/p/7395227.html
Copyright © 2011-2022 走看看