利用AUDIT查看数据库表结构变化

一朋友问我,想查看一下数据库中,表里边一个字段哪天修改字段长度了,我想到了用数据库审计来实现,做个实验,来看下。
朋友那边数据库版本是 ORACLE 10g,10g版本默认没开启审计功能,需要开启审计。

C:\Documents and Settings\Administrator>sqlplus / as sysdba

SQL*Plus: Release 10.2.0.3.0 - Production on 星期一 12月 30 09:57:39 2013

Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> show parameter audit

NAME                                 TYPE
------------------------------------ ----------------------
VALUE
------------------------------
audit_file_dest                      string
D:\ORACLE\PRODUCT\10.2.0\ADMIN
\YING8\ADUMP
audit_sys_operations                 boolean
FALSE
audit_trail                          string
NONE
SQL> alter system set audit_trail=DB_EXTENDED ;
alter system set audit_trail=DB_EXTENDED
                 *
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified


SQL> alter system set audit_trail=DB_EXTENDED scope=spfile;--静态参数,这里的DB_EXTENDED具有捕获SQL的功能。

System altered.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  583008256 bytes
Fixed Size                  1291868 bytes
Variable Size             213911972 bytes
Database Buffers          360710144 bytes
Redo Buffers                7094272 bytes
Database mounted.
Database opened.
SQL> show parameter audit

NAME                                 TYPE
------------------------------------ ----------------------
VALUE
------------------------------
audit_file_dest                      string
D:\ORACLE\PRODUCT\10.2.0\ADMIN
\YING8\ADUMP
audit_sys_operations                 boolean
FALSE
audit_trail                          string
DB_EXTENDED
SQL> conn wzz/wzz
Connected.
SQL> desc wh2
ERROR:
ORA-04043: object wh2 does not exist


SQL> create table wh2 (id int);

Table created.

SQL> audit alter on wh2 by access;

Audit succeeded.

SQL> select * from dba_audit_trail;

no rows selected

SQL> alter table wh2 add name varchar2(20);

Table altered.

SQL> select timestamp,owner,obj_name,action,action_name,sql_text from dba_audit_trail;

TIMESTAMP        OWNER OBJ_N     ACTION ACTION_NAME                                              SQL_TEXT
---------------- ----- ----- ---------- -------------------------------------------------------- ------------------------------
30-12月-2013     WZZ   WH2           15 ALTER TABLE                                              alter table wh2 add name varch
                                                                                                 ar2(20)



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26084062/viewspace-1065526/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/26084062/viewspace-1065526/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值