ch15.htm
来自「Teach yourself Oracle8 in 21 day」· HTM 代码 · 共 702 行 · 第 1/3 页
HTM
702 行
<P>
<LI><TT>WHENEVER NOT SUCCESSFUL</TT> --Causes an audit record to be written only
when the SQL statement was unsuccessful. If omitted, all SQL statements are audited
regardless of success.
</UL>
<P>Besides auditing particular SQL statements by statement or privilege, you may
also audit schema objects, as shown in the next section.</P>
<P><FONT COLOR="#000077"><B>Auditing Objects</B></FONT></P>
<P>Auditing schema objects is very similar to auditing SQL statements. You can also
audit access to particular schema objects. The syntax used to audit objects is very
similar to the syntax used to audit SQL statements, as shown here:</P>
<PRE><FONT COLOR="#0066FF">AUDIT
Object_Option [, Object_Option ...]
ON [schema.]object] or ON DIRECTORY dir_name or ON DEFAULT
[BY SESSION or BY ACCESS]
[WHENEVER SUCCESSFUL or WHENEVER NOT SUCCESSFUL]
</FONT></PRE>
<P>This statement is all that is necessary to enable auditing. Following are the
explanations of the parameters:
<UL>
<LI>Object_Option--Specifies the type of operation that is audited. These keywords
are SQL commands such as <TT>ALTER</TT>, <TT>DELETE</TT>, <TT>SELECT</TT>, and so
on, and are described in detail in the Oracle documentation. One of the object options
is <TT>ALL</TT>, specifying that all operations are to be audited.
<P>
<LI><TT>ON </TT>schema<TT>.]</TT>object--Specifies the schema or schema object that
will be audited.
<P>
<LI><TT>ON DIRECTOR</TT> dir_name--Specifies the directory that is being audited.
<P>
<LI><TT>ON DEFAULT</TT>--Specifies that objects that have not even been created will
be audited with the same auditing options as other objects.
<P>
<LI><TT>BY SESSION</TT>--Causes Oracle auditing to write only one record for each
SQL statement issued in a session, so duplicate SQL statements are not logged.
<P>
<LI><TT>BY ACCESS</TT>--The opposite of <TT>BY SESSION</TT>. Causes an audit record
to be written for each SQL statement issued.
<P>
<LI><TT>WHENEVER SUCCESSFUL</TT>--Causes an audit record to be written only when
the SQL statement was successful. If omitted, all SQL statements are audited regardless
of success.
<P>
<LI><TT>WHENEVER NOT SUCCESSFUL</TT> --Causes an audit record to be written only
when the SQL statement was unsuccessful. If omitted, all SQL statements are audited
regardless of whether it is successful or not.
</UL>
<P>This is the syntax necessary to perform auditing on schema objects.
<BLOCKQUOTE>
<P>
<HR>
<FONT COLOR="#000077"><B>TIP:</B></FONT><B> </B>If you audit <TT>WHENEVER NOT SUCCESSFUL</TT>,
a record is kept of unsuccessful attempts at various operations. If you suspect that
a user is trying to tamper with the system, this information can be very useful.
<HR>
</BLOCKQUOTE>
<H3><FONT COLOR="#000077"><B>Protecting the Audit Trail</B></FONT></H3>
<P>It is important that you protect the audit trail if you suspect unusual behavior.
In this manner, if there is malicious behavior going on, the party or parties involved
cannot cover their tracks. You protect the audit trail with the following two steps:
<DL>
<DD><B>1.</B> Limit the <TT>DELETE ANY TABLE</TT> system privilege to the database
administrators only. This keeps other users from being able to delete the audit trail.
<P><B>2. </B>Enable auditing on the audit trail itself. You do this with the following
SQL statement:
</DL>
<BLOCKQUOTE>
<PRE><FONT COLOR="#0066FF">AUDIT INSERT, UPDATE, DELETE
ON sys.aud$
BY ACCESS;</FONT></PRE>
</BLOCKQUOTE>
<PRE><FONT COLOR="#0066FF"></FONT></PRE>
<P>This will cause all access to the audit trail to be audited, thus indicating whether
someone is covering up something.
<H3><FONT COLOR="#000077"><B>Viewing Audit Information</B></FONT></H3>
<P>As mentioned in the beginning of this lesson, there are a number of views into
the audit trail created by the <TT>CATAUDIT.SQL</TT> administrative script. You can
select these views to provide useful auditing information. Here is a description
of the most relevant of the views:
<UL>
<LI><TT>[USER or DBA]_AUDIT_OBJECT</TT>--Audit trail entries for objects that are
audited.
<P>
<LI><TT>[USER or DBA]_AUDIT_SESSION</TT>--Audit entries for <TT>CONNECT</TT> and
<TT>DISCONNECT</TT> operations.
<P>
<LI><TT>[USER or DBA]_AUDIT_STATEMENT</TT>--The audit trail concerning <TT>GRANT</TT>,
<TT>REVOKE</TT>, <TT>AUDIT</TT>, <TT>NOAUDIT</TT>, and <TT>ALTER SYSTEM</TT> commands.
<P>
<LI><TT>[USER or DBA]_AUDIT_TRAIL</TT>--All audit trail entries.
</UL>
<P>By selecting from these views, you can retrieve information about the audit trails.
The specific information in the audit trails may vary, but all of them contain the
same basic information:
<UL>
<LI>Username
<P>
<LI>Session identifier
<P>
<LI>Terminal identifier
<P>
<LI>Object being accessed
<P>
<LI>Operation performed or attempted
<P>
<LI>Completion code
<P>
<LI>Date and time stamp
</UL>
<P>The auditing information can be useful, but should be used with care to avoid
consuming excess system resources. Using auditing as necessary and selectively can
be very enlightening.
<BLOCKQUOTE>
<P>
<HR>
<FONT COLOR="#000077"><B>WARNING:</B></FONT><B> </B>Because of the overhead auditing
adds to the system, it should be used sparingly. Only audit the events that are necessary
and only audit when necessary.
<HR>
</BLOCKQUOTE>
<H2><FONT COLOR="#000077"><B>Summary</B></FONT></H2>
<P>In today's lesson you have learned about managing job queues and the Oracle auditing
facility. Oracle job queues are used to divert the execution of an operation to a
later time, thus allowing you to schedule jobs. By using the Oracle job-queuing facility,
you can easily schedule jobs to be run at various times or on a regular schedule.
This allows you to automate many of the repetitive tasks that need to be done. You
have learned how to schedule jobs using both the Enterprise Manager and the stored
procedures in the <TT>DBMS_JOB</TT> package.</P>
<P>The Oracle auditing facility is used to log various database operations such as
when they occurred and who performed that operation. Auditing is important if one
or more incidences have occurred to make you suspicious of the activity of one or
more users. Through auditing, a record will be made of this activity that can be
used in tracking down the party at fault. Auditing is also useful to periodically
monitor the activity of the system and to allow you to make adjustments to improve
performance or usability of the system.
<H2><FONT COLOR="#000077"><B>What's Next?</B></FONT></H2>
<P>In tomorrow's lesson, "Understanding Effective Backup Techniques," you
will begin to learn about one of the most important tasks the DBA is charged with:
backup and recovery. In the next three days you will learn various techniques for
putting together a backup and recovery plan and various methods of quick recovery
and fault tolerance. This is one of my favorite topics, and I hope you will enjoy
it too.
<H2><FONT COLOR="#000077"><B>Q&A</B></FONT></H2>
<DL>
<DD><B>Q What is the job queue used for?</B>
<P><B>A</B> The Oracle job-queuing mechanism is used to defer the execution of database
operations or to run operations in the background.</P>
<P><B>Q Who can use the job queues?</B></P>
<P><B>A</B> Any user can use the job queues, but use of the Oracle Enterprise Manager
is usually limited to the database administrators.</P>
<P><B>Q What is auditing used for?</B></P>
<P><B>A</B> Auditing is used either to characterize database activity or to find
the source of suspicious activity.</P>
<P><B>Q Who uses auditing?</B></P>
<P><B>A</B> Auditing is limited to database administrators. There is no reason for
users to need to use the auditing facilities.
</DL>
<H2><FONT COLOR="#000077"><B>Workshop</B></FONT></H2>
<P>The workshop provides quiz questions to help you solidify your understanding of
the material covered and exercises to provide you with experience in using what you've
learned. Find answers to the quiz questions in Appendix A, "Answers."
<H3><FONT COLOR="#000077"><B>Quiz</B></FONT></H3>
<DL>
<DD><B>1.</B> What is the job-scheduling facility used for?
<P><B>2. </B>What kind of jobs can be scheduled?</P>
<P><B>3.</B> Can only database operations be scheduled?</P>
<P><B>4. </B>Should a new user account be created for job queuing?</P>
<P><B>5. </B>What NT user right needs to be created for this user account?</P>
<P><B>6. </B>Can jobs be run on remote systems?</P>
<P><B>7.</B> What kinds of scheduling can be done?</P>
<P><B>8.</B> What needs to be configured in the Enterprise Manager?</P>
<P><B>9.</B> Why might you need to enable auditing?</P>
<P><B>10.</B> What do you need to watch out for with auditing?
</DL>
<H3><FONT COLOR="#000077"><B>Exercises</B></FONT></H3>
<DL>
<DD><B>1.</B> Invoke the Enterprise Manager and look for any running jobs.
<P><B>2.</B> Create a test job using the Enterprise Manager. This job can be a simple
select operation.</P>
<P><B>3.</B> Schedule this job to run every week.</P>
<P><B>4. </B>Delete this job from the job queue.
</DL>
<CENTER>
<P>
<HR>
<A HREF="../wk3/wk3.htm"><IMG SRC="../buttonart/previous.gif" WIDTH="128" HEIGHT="28"
ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../ch16/ch16.htm"><IMG
SRC="../buttonart/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"
BORDER="0"></A><A HREF="../index.htm"><IMG SRC="../buttonart/contents.gif" WIDTH="128"
HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A> <BR>
<BR>
<BR>
<IMG SRC="../buttonart/corp.gif" WIDTH="284" HEIGHT="45" ALIGN="BOTTOM" ALT="Macmillan Computer Publishing USA"
BORDER="0"></P>
<P>© <A HREF="../copy.htm">Copyright</A>, Macmillan Computer Publishing. All
rights reserved.
</CENTER>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?