search
HomeDatabaseMysql TutorialOracle数据库审计用法实例

本节是从ORACLE METALINK的DOC:167293.1翻译整理而来的。通过举例的方式来说明ORACLE审计的用法。ORACLE的审计可以从语句级、对象

本节是从Oracle METALINK的DOC:167293.1翻译整理而来的。通过举例的方式来说明ORACLE审计的用法。

ORACLE的审计可以从语句级、对象级和权限级几个方面进行。同样的,SYSDBA和SYSOPER用户的行为也可以被审计(从ORACLE 9i Release 2,,9.2.0.1开始,SYS用户可以通过设置AUDIT_SYS_OPERATIONS参数来进行审计)。

1.对象级审计

可以被审计的对象包括表、视图、序列发生器、包、存储过程等。由于对象的依赖性问题,可能同一件事情可能会产生多条审计信息。比如说某个函数关联到某个视图,某个视图关联到某个表。

对象级审计只能针对整个数据库的用户而不能对于某个用户进行审计。要查看对象级审计具有哪些审计选项,可以查询ALL_DEF_AUDIT_OPTS视图。


SQL> connect system/manager

SQL> select * from all_def_audit_opts;


ALT AUD COM DEL GRAINDINS LOC REN SEL UPD REF EXE

--- --- --- --- --- --- --- --- --- --- --- --- ---

-/- -/- -/- -/- -/- -/- -/- -/- -/- -/- -/- -/- -/-


下面的例子是对SCOTT.EMP进行审计:

SQL> connect system/manager

SQL> audit select on SCOTT.emp by session;

查看审计信息是否被记录了:

SQL> col owner format a7

SQL> col object_name format a7

SQL>select * from dba_obj_audit_opts

where wner='SCOTT' and OBJECT_NAME='EMP';


OWNEROBJECT_ OBJECT_TY ALT AUD COM DEL GRAINDINS LOC REN SEL UPD REF EXE

----- ----- --------- --- --- --- --- --- --- --- --- --- --- --- --- ---

SCOTTEMPTABLE-/- -/- -/- -/- -/- -/- -/- -/- -/- S/S -/- -/- -/-

以下的语句可以生成一些审计信息:

SQL> connect scott/tiger

SQL> select * from emp;

SQL> connect TEST/TEST

SQL> select * from scott.emp;

ERROR at line 1:

ORA-00942: table or view does not exist

SQL> connect system/manager

SQL> select * from scott.emp;


审计结果


SQL> connect system/manager

SQL> col username format a8

SQL> col priv_used format 999

SQL> /


SQL>select username, priv_used, ses_actions from

dba_audit_object

where obj_name='EMP' and wner='SCOTT';


结果


USERNAMEPRIV_USEDSES_ACTIONS

------------------------------ ---------- -------------------

SCOTT---------S------

TEST

SYSTEMSELECT ANY ---------S------

2.从权限级进行审计

所有的系统权限都可以进行审计。从SYSTEM_PRIVILEGE_MAP中可查询到所有的系统权限。如果你要对一个不属于该视图中的权限进行审计,会出现错误:

SQL> audit drop snapshot by access;

audit drop snapshot by access

*

ERROR at line 1:

ORA-00956: missing or invalid auditing option


SQL> connect system/manager

SQL> select * from system_privilege_map;

 

PRIVILEGE NAME

---------- ----------------------------------------

-3 ALTER SYSTEM

-4 AUDIT SYSTEM

-5 CREATE SESSION

-6 ALTER SESSION

-7 RESTRICTED SESSION

-10 CREATE TABLESPACE

-11 ALTER TABLESPACE

-12 MANAGE TABLESPACE

-13 DROP TABLESPACE

.....

-167 GRANT ANY PRIVILEGE

-172 CREATE SNAPSHOT

-173 CREATE ANY SNAPSHOT

-174 ALTER ANY SNAPSHOT

-175 DROP ANY SNAPSHOT

-194 WRITEDOWN DBLOW

-195 READUP DBHIGH

-196 WRITEUP DBHIGH

-197 WRITEDOWN

-198 READUP

-199 WRITEUP

linux

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What Are the Limitations of Using Views in MySQL?What Are the Limitations of Using Views in MySQL?May 14, 2025 am 12:10 AM

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

Securing Your MySQL Database: Adding Users and Granting PrivilegesSecuring Your MySQL Database: Adding Users and Granting PrivilegesMay 14, 2025 am 12:09 AM

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

What Factors Influence the Number of Triggers I Can Use in MySQL?What Factors Influence the Number of Triggers I Can Use in MySQL?May 14, 2025 am 12:08 AM

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

MySQL: Is it safe to store BLOB?MySQL: Is it safe to store BLOB?May 14, 2025 am 12:07 AM

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

MySQL: Adding a user through a PHP web interfaceMySQL: Adding a user through a PHP web interfaceMay 14, 2025 am 12:04 AM

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools