home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 February / PCWK0296.iso / po7_win / db / rdbms71 / cataudit.sql < prev    next >
Text File  |  1994-08-07  |  48KB  |  1,244 lines

  1. rem 
  2. rem $Header: cataudit.sql 7010300.1 94/02/24 18:25:21 snataraj Generic<base> $ audit.sql 
  3. rem 
  4. Rem Copyright (c) 1990 by Oracle Corporation
  5. Rem NAME
  6. Rem    CATAUDIT.SQL
  7. Rem FUNCTION
  8. Rem    Creates data dictionary views for auditing. 
  9. Rem NOTES
  10. Rem    Must be run while connected to SYS or INTERNAL.
  11. Rem MODIFIED
  12. Rem     jbellemo   11/09/93 -  #170173: change uid to userenv schemaid
  13. Rem     wmaimone   11/23/92 -  wrap rawtolab around labels 
  14. Rem     dleary     11/12/92 -  add OER(2024) not exists error 
  15. Rem     tpystyne   11/07/92 -  use create or replace view 
  16. Rem     vraghuna   10/28/92 -  bug 130560 - move map tables in sql.bsq 
  17. Rem    glumpkin   10/14/92 -  renamed from audit.sql
  18. Rem     rlim       09/25/92 -  #128468 - remove dba synonyms already
  19. Rem                            defined in dba_syn.sql 
  20. Rem     ajasuja    06/02/92 -  new auditing codes 
  21. Rem     ajasuja    02/12/92 -  add ses$label, obj$label columns 
  22. Rem     ajasuja    12/31/91 -  fix dba_audit_trail view 
  23. Rem     ajasuja    12/30/91 -  audit EXISTS 
  24. Rem     ajasuja    11/27/91 -  add system privilege auditing 
  25. Rem     smcadams   10/19/91 -  tweak audit_action table 
  26. Rem     rlim       07/30/91 -         moved dba synonyms to dba_synonyms.sql 
  27. Rem     smcadams   06/09/91 -         sync with catalog.sql 
  28. Rem     smcadams   05/07/91 -         re-sync audit action decoding table with 
  29. Rem     jwijaya    04/12/91 -         remove LINKNAME IS NULL 
  30. Rem     smcadams   04/08/91 -         remove 'ANY' from audit option descriptio
  31. Rem     smcadams   04/02/91 -         add action to audit_actions 
  32. Rem     smcadams   04/02/91 -         add a couple more stmt_audit_opts 
  33. Rem     rkooi      04/01/91 -         add 'o.linkname IS NULL' clause 
  34. Rem   Chaudhr    04/30/90 - Add procedure and trigger stuff
  35. Rem                       - Rename the following objects:
  36. Rem                       -  audit_option_map    -> stmt_audit_option_map
  37. Rem                       -  dba_sys_audit_opts  -> dba_stmt_audit_opts
  38. Rem                       -  dba_tab_audit_opts  -> dba_obj_audit_opts
  39. Rem                       -  user_tab_audit_opts -> user_obj_audit_opts
  40. Rem   Chaudhr    03/09/90 - Creation
  41. Rem
  42.  
  43. remark
  44. remark AUDITING VIEWS
  45. remark
  46. remark The auditing views can be dropped by running NOAUDIT.SQL, and recreated
  47. remark by running AUDIT.SQL.
  48. remark
  49. remark  Every auditing table and view has a comment on it describing its 
  50. remark  purpose. The DBA_AUDIT_TRAIL and USER_AUDIT_TRAIL views have comments
  51. remark  on all their columns, but other views based on these views don't have 
  52. remark  comment on their columns since the are exactly the same as as the
  53. remark  base view columns. All columns in the auditing tables also have 
  54. remark  comments on them.
  55. remark
  56. remark  STMT_AUDIT_OPTION_MAP now in sql.bsq
  57. remark
  58. remark  AUDIT_ACTIONS maps an action number to the action name.
  59. remark  The table is accessible to public.
  60. remark
  61. /
  62. drop table AUDIT_ACTIONS
  63. /
  64. create table AUDIT_ACTIONS(
  65.   action number not null, name varchar2(27) not null)
  66. /
  67. comment on table AUDIT_ACTIONS is
  68. 'Description table for audit trail action type codes.  Maps action type numbers to action type names'
  69. /
  70. comment on column AUDIT_ACTIONS.ACTION is
  71. 'Numeric audit trail action type code'
  72. /
  73. comment on column AUDIT_ACTIONS.NAME is
  74. 'Name of the type of audit trail action'
  75. /
  76. insert into audit_actions values (0, 'UNKNOWN');
  77. insert into audit_actions values (1, 'CREATE TABLE');
  78. insert into audit_actions values (2, 'INSERT');
  79. insert into audit_actions values (3, 'SELECT');
  80. insert into audit_actions values (4, 'CREATE CLUSTER');
  81. insert into audit_actions values (5, 'ALTER CLUSTER');
  82. insert into audit_actions values (6, 'UPDATE');
  83. insert into audit_actions values (7, 'DELETE');
  84. insert into audit_actions values (8, 'DROP CLUSTER');
  85. insert into audit_actions values (9, 'CREATE INDEX');
  86. insert into audit_actions values (10, 'DROP INDEX');
  87. insert into audit_actions values (11, 'ALTER INDEX');
  88. insert into audit_actions values (12, 'DROP TABLE');
  89. insert into audit_actions values (13, 'CREATE SEQUENCE');
  90. insert into audit_actions values (14, 'ALTER SEQUENCE');
  91. insert into audit_actions values (15, 'ALTER TABLE');
  92. insert into audit_actions values (16, 'DROP SEQUENCE');
  93. insert into audit_actions values (17, 'GRANT OBJECT');
  94. insert into audit_actions values (18, 'REVOKE OBJECT');
  95. insert into audit_actions values (19, 'CREATE SYNONYM');
  96. insert into audit_actions values (20, 'DROP SYNONYM');
  97. insert into audit_actions values (21, 'CREATE VIEW');
  98. insert into audit_actions values (22, 'DROP VIEW');
  99. insert into audit_actions values (23, 'VALIDATE INDEX');
  100. insert into audit_actions values (24, 'CREATE PROCEDURE');
  101. insert into audit_actions values (25, 'ALTER PROCEDURE');
  102. insert into audit_actions values (26, 'LOCK');
  103. insert into audit_actions values (27, 'NO-OP');
  104. insert into audit_actions values (28, 'RENAME');
  105. insert into audit_actions values (29, 'COMMENT');
  106. insert into audit_actions values (30, 'AUDIT OBJECT');
  107. insert into audit_actions values (31, 'NOAUDIT OBJECT');
  108. insert into audit_actions values (32, 'CREATE DATABASE LINK');
  109. insert into audit_actions values (33, 'DROP DATABASE LINK');
  110. insert into audit_actions values (34, 'CREATE DATABASE');
  111. insert into audit_actions values (35, 'ALTER DATABASE');
  112. insert into audit_actions values (36, 'CREATE ROLLBACK SEG');
  113. insert into audit_actions values (37, 'ALTER ROLLBACK SEG');
  114. insert into audit_actions values (38, 'DROP ROLLBACK SEG');
  115. insert into audit_actions values (39, 'CREATE TABLESPACE');
  116. insert into audit_actions values (40, 'ALTER TABLESPACE');
  117. insert into audit_actions values (41, 'DROP TABLESPACE');
  118. insert into audit_actions values (42, 'ALTER SESSION');
  119. insert into audit_actions values (43, 'ALTER USER');
  120. insert into audit_actions values (44, 'COMMIT');
  121. insert into audit_actions values (45, 'ROLLBACK');
  122. insert into audit_actions values (46, 'SAVEPOINT');
  123. insert into audit_actions values (47, 'PL/SQL EXECUTE');
  124. insert into audit_actions values (48, 'SET TRANSACTION');
  125. insert into audit_actions values (49, 'ALTER SYSTEM');
  126. insert into audit_actions values (50, 'EXPLAIN');
  127. insert into audit_actions values (51, 'CREATE USER');
  128. insert into audit_actions values (52, 'CREATE ROLE');
  129. insert into audit_actions values (53, 'DROP USER');
  130. insert into audit_actions values (54, 'DROP ROLE');
  131. insert into audit_actions values (55, 'SET ROLE');
  132. insert into audit_actions values (56, 'CREATE SCHEMA');
  133. insert into audit_actions values (57, 'CREATE CONTROL FILE');
  134. insert into audit_actions values (58, 'DROP PROCEDURE');
  135. insert into audit_actions values (59, 'CREATE TRIGGER');
  136. insert into audit_actions values (60, 'ALTER TRIGGER');
  137. insert into audit_actions values (61, 'DROP TRIGGER');
  138. insert into audit_actions values (62, 'ANALYZE TABLE');
  139. insert into audit_actions values (63, 'ANALYZE INDEX');
  140. insert into audit_actions values (64, 'ANALYZE CLUSTER');
  141. insert into audit_actions values (65, 'CREATE PROFILE');
  142. insert into audit_actions values (66, 'DROP PROFILE');
  143. insert into audit_actions values (67, 'ALTER PROFILE');
  144. insert into audit_actions values (68, 'DROP PROCEDURE');
  145. insert into audit_actions values (70, 'ALTER RESOURCE COST');
  146. insert into audit_actions values (71, 'CREATE SNAPSHOT LOG');
  147. insert into audit_actions values (72, 'ALTER SNAPSHOT LOG');
  148. insert into audit_actions values (73, 'DROP SNAPSHOT LOG');
  149. insert into audit_actions values (74, 'CREATE SNAPSHOT');
  150. insert into audit_actions values (75, 'ALTER SNAPSHOT');
  151. insert into audit_actions values (76, 'DROP SNAPSHOT');
  152. insert into audit_actions values (79, 'ALTER ROLE');
  153. insert into audit_actions values (85, 'TRUNCATE TABLE');
  154. insert into audit_actions values (86, 'TRUNCATE CLUSTER');
  155. insert into audit_actions values (91, 'CREATE FUNCTION');
  156. insert into audit_actions values (92, 'ALTER FUNCTION');
  157. insert into audit_actions values (93, 'DROP FUNCTION');
  158. insert into audit_actions values (94, 'CREATE PACKAGE');
  159. insert into audit_actions values (95, 'ALTER PACKAGE');
  160. insert into audit_actions values (96, 'DROP PACKAGE');
  161. insert into audit_actions values (97, 'CREATE PACKAGE BODY');
  162. insert into audit_actions values (98, 'ALTER PACKAGE BODY');
  163. insert into audit_actions values (99, 'DROP PACKAGE BODY');
  164. insert into audit_actions values (100, 'LOGON');
  165. insert into audit_actions values (101, 'LOGOFF');
  166. insert into audit_actions values (102, 'LOGOFF BY CLEANUP');
  167. insert into audit_actions values (103, 'SESSION REC');
  168. insert into audit_actions values (104, 'SYSTEM AUDIT');
  169. insert into audit_actions values (105, 'SYSTEM NOAUDIT');
  170. insert into audit_actions values (106, 'AUDIT DEFAULT');
  171. insert into audit_actions values (107, 'NOAUDIT DEFAULT');
  172. insert into audit_actions values (108, 'SYSTEM GRANT');
  173. insert into audit_actions values (109, 'SYSTEM REVOKE');
  174. insert into audit_actions values (110, 'CREATE PUBLIC SYNONYM');
  175. insert into audit_actions values (111, 'DROP PUBLIC SYNONYM');
  176. insert into audit_actions values (112, 'CREATE PUBLIC DATABASE LINK');
  177. insert into audit_actions values (113, 'DROP PUBLIC DATABASE LINK');
  178. insert into audit_actions values (114, 'GRANT ROLE');
  179. insert into audit_actions values (115, 'REVOKE ROLE');
  180. insert into audit_actions values (116, 'EXECUTE PROCEDURE');
  181. insert into audit_actions values (117, 'USER COMMENT');
  182. insert into audit_actions values (118, 'ENABLE TRIGGER');
  183. insert into audit_actions values (119, 'DISABLE TRIGGER');
  184. insert into audit_actions values (120, 'ENABLE ALL TRIGGERS');
  185. insert into audit_actions values (121, 'DISABLE ALL TRIGGERS');
  186. commit;
  187. create unique index I_AUDIT_ACTIONS on audit_actions(action,name) nocompress
  188. /
  189. drop public synonym AUDIT_ACTIONS
  190. /
  191. create public synonym AUDIT_ACTIONS for AUDIT_ACTIONS
  192. /
  193. grant select on AUDIT_ACTIONS to public
  194. /
  195.  
  196. remark
  197. remark  FAMILY "DEF_AUDIT_OPTS"
  198. remark  Single row view indicating the default auditing options
  199. remark  for newly created objects.
  200. remark  This family has an ALL member only, since the default is
  201. remark  system-wide and applies to all accessible objects.
  202. remark
  203. create or replace view ALL_DEF_AUDIT_OPTS
  204.     (ALT,
  205.      AUD,
  206.      COM,
  207.      DEL,
  208.      GRA,
  209.      IND,
  210.      INS,
  211.      LOC,
  212.      REN,
  213.      SEL,
  214.      UPD,
  215.      REF,
  216.      EXE)
  217. as
  218. select substr(t.audit$, 1, 1) || '/' || substr(t.audit$, 2, 1),
  219.        substr(t.audit$, 3, 1) || '/' || substr(t.audit$, 4, 1),
  220.        substr(t.audit$, 5, 1) || '/' || substr(t.audit$, 6, 1),
  221.        substr(t.audit$, 7, 1) || '/' || substr(t.audit$, 8, 1),
  222.        substr(t.audit$, 9, 1) || '/' || substr(t.audit$, 10, 1),
  223.        substr(t.audit$, 11, 1) || '/' || substr(t.audit$, 12, 1),
  224.        substr(t.audit$, 13, 1) || '/' || substr(t.audit$, 14, 1),
  225.        substr(t.audit$, 15, 1) || '/' || substr(t.audit$, 16, 1),
  226.        substr(t.audit$, 17, 1) || '/' || substr(t.audit$, 18, 1),
  227.        substr(t.audit$, 19, 1) || '/' || substr(t.audit$, 20, 1),
  228.        substr(t.audit$, 21, 1) || '/' || substr(t.audit$, 22, 1),
  229.        substr(t.audit$, 23, 1) || '/' || substr(t.audit$, 24, 1),
  230.        substr(t.audit$, 25, 1) || '/' || substr(t.audit$, 26, 1)
  231. from sys.obj$ o, sys.tab$ t
  232. where o.obj# = t.obj#
  233.   and o.owner# = 0
  234.   and o.name = '_default_auditing_options_'
  235. /
  236. comment on table ALL_DEF_AUDIT_OPTS is
  237. 'Auditing options for newly created objects'
  238. /
  239. comment on column ALL_DEF_AUDIT_OPTS.ALT is
  240. 'Auditing ALTER WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  241. /
  242. comment on column ALL_DEF_AUDIT_OPTS.AUD is
  243. 'Auditing AUDIT WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  244. /
  245. comment on column ALL_DEF_AUDIT_OPTS.COM is
  246. 'Auditing COMMENT WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  247. /
  248. comment on column ALL_DEF_AUDIT_OPTS.DEL is
  249. 'Auditing DELETE WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  250. /
  251. comment on column ALL_DEF_AUDIT_OPTS.GRA is
  252. 'Auditing GRANT WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  253. /
  254. comment on column ALL_DEF_AUDIT_OPTS.IND is
  255. 'Auditing INDEX WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  256. /
  257. comment on column ALL_DEF_AUDIT_OPTS.INS is
  258. 'Auditing INSERT WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  259. /
  260. comment on column ALL_DEF_AUDIT_OPTS.LOC is
  261. 'Auditing LOCK WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  262. /
  263. comment on column ALL_DEF_AUDIT_OPTS.REN is
  264. 'Auditing RENAME WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  265. /
  266. comment on column ALL_DEF_AUDIT_OPTS.SEL is
  267. 'Auditing SELECT WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  268. /
  269. comment on column ALL_DEF_AUDIT_OPTS.UPD is
  270. 'Auditing UPDATE WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  271. /
  272. comment on column ALL_DEF_AUDIT_OPTS.REF is
  273. 'Auditing REFERENCES WHENEVER SUCCESSFUL / UNSUCCESSFUL (not used)'
  274. /
  275. comment on column ALL_DEF_AUDIT_OPTS.EXE is
  276. 'Auditing EXECUTE WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  277. /
  278. drop public synonym ALL_DEF_AUDIT_OPTS
  279. /
  280. create public synonym ALL_DEF_AUDIT_OPTS for ALL_DEF_AUDIT_OPTS
  281. /
  282. grant select on ALL_DEF_AUDIT_OPTS to PUBLIC
  283. /
  284.  
  285.  
  286. remark
  287. remark  FAMILY "OBJ_AUDIT_OPTS"
  288. remark  Auditing options on objects.  Only "user_" and "dba_" members.
  289. remark  A user is not allowed to see audit options for other people's objects.
  290. remark
  291. remark  These views indicate what kind of audit trail entries (none,
  292. remark  session-level, or access-level) are generated by the success or failure
  293. remark  of each possible operation on a table or view (e.g., select, alter).
  294. remark
  295. remark  The values in the columns ALT through UPD are three character
  296. remark  strings like 'A/S', 'A/-'.  The letters 'A', 'S', and '-' correspond to
  297. remark  different levels of detail called Access, Session and None.  The
  298. remark  character before the slash determines the auditing level if the action
  299. remark  is successful.  The character after the slash determines auditing level
  300. remark  if the operation fails for any reason.
  301. remark
  302. remark  This compressed three character format has been chosen to make all
  303. remark  the information fit on a single line.  The column names are
  304. remark  three chars long for the same reason.  The alternative is to use long
  305. remark  column names to improve readability, but
  306. remark  serious users can get further documentation using the describe
  307. remark  column statement.  I do not expect novice users to be looking at audit
  308. remark  information.  Another alternative is to have separate columns for the
  309. remark  success and failure settings.  This would eliminate the need to
  310. remark  use the substr function in views built on top of these views,
  311. remark  but the advantage to users of making information fit on one line
  312. remark  overrides the hassle to view-implementors of using the substr function.
  313. remark
  314. create or replace view USER_OBJ_AUDIT_OPTS 
  315.     (OBJECT_NAME, 
  316.      OBJECT_TYPE, 
  317.      ALT,
  318.          AUD,
  319.          COM,
  320.          DEL,
  321.           GRA,
  322.           IND,
  323.          INS,
  324.          LOC,
  325.          REN,
  326.          SEL,
  327.          UPD,
  328.          REF,
  329.      EXE)
  330. as
  331. select o.name, 'TABLE',
  332.        substr(t.audit$, 1, 1) || '/' || substr(t.audit$, 2, 1),
  333.        substr(t.audit$, 3, 1) || '/' || substr(t.audit$, 4, 1),
  334.        substr(t.audit$, 5, 1) || '/' || substr(t.audit$, 6, 1),
  335.        substr(t.audit$, 7, 1) || '/' || substr(t.audit$, 8, 1),
  336.        substr(t.audit$, 9, 1) || '/' || substr(t.audit$, 10, 1),
  337.        substr(t.audit$, 11, 1) || '/' || substr(t.audit$, 12, 1),
  338.        substr(t.audit$, 13, 1) || '/' || substr(t.audit$, 14, 1),
  339.        substr(t.audit$, 15, 1) || '/' || substr(t.audit$, 16, 1),
  340.        substr(t.audit$, 17, 1) || '/' || substr(t.audit$, 18, 1),
  341.        substr(t.audit$, 19, 1) || '/' || substr(t.audit$, 20, 1),
  342.        substr(t.audit$, 21, 1) || '/' || substr(t.audit$, 22, 1),
  343.        substr(t.audit$, 23, 1) || '/' || substr(t.audit$, 24, 1),
  344.        substr(t.audit$, 25, 1) || '/' || substr(t.audit$, 26, 1)
  345. from sys.obj$ o, sys.tab$ t
  346. where o.type = 2
  347.   and not (o.owner# = 0 and o.name = '_default_auditing_options_')
  348.   and o.owner# = userenv('SCHEMAID')
  349.   and o.obj# = t.obj#
  350. union all
  351. select o.name, 'VIEW',
  352.        substr(v.audit$, 1, 1) || '/' || substr(v.audit$, 2, 1),
  353.        substr(v.audit$, 3, 1) || '/' || substr(v.audit$, 4, 1),
  354.        substr(v.audit$, 5, 1) || '/' || substr(v.audit$, 6, 1),
  355.        substr(v.audit$, 7, 1) || '/' || substr(v.audit$, 8, 1),
  356.        substr(v.audit$, 9, 1) || '/' || substr(v.audit$, 10, 1),
  357.        substr(v.audit$, 11, 1) || '/' || substr(v.audit$, 12, 1),
  358.        substr(v.audit$, 13, 1) || '/' || substr(v.audit$, 14, 1),
  359.        substr(v.audit$, 15, 1) || '/' || substr(v.audit$, 16, 1),
  360.        substr(v.audit$, 17, 1) || '/' || substr(v.audit$, 18, 1),
  361.        substr(v.audit$, 19, 1) || '/' || substr(v.audit$, 20, 1),
  362.        substr(v.audit$, 21, 1) || '/' || substr(v.audit$, 22, 1),
  363.        substr(v.audit$, 23, 1) || '/' || substr(v.audit$, 24, 1),
  364.        substr(v.audit$, 25, 1) || '/' || substr(v.audit$, 26, 1)
  365. from sys.obj$ o, sys.view$ v
  366. where o.type = 4
  367.   and o.owner# = userenv('SCHEMAID')
  368.   and o.obj# = v.obj#
  369. union all
  370. select o.name, 'SEQUENCE',
  371.        substr(s.audit$, 1, 1) || '/' || substr(s.audit$, 2, 1),
  372.        substr(s.audit$, 3, 1) || '/' || substr(s.audit$, 4, 1),
  373.        substr(s.audit$, 5, 1) || '/' || substr(s.audit$, 6, 1),
  374.        substr(s.audit$, 7, 1) || '/' || substr(s.audit$, 8, 1),
  375.        substr(s.audit$, 9, 1) || '/' || substr(s.audit$, 10, 1),
  376.        substr(s.audit$, 11, 1) || '/' || substr(s.audit$, 12, 1),
  377.        substr(s.audit$, 13, 1) || '/' || substr(s.audit$, 14, 1),
  378.        substr(s.audit$, 15, 1) || '/' || substr(s.audit$, 16, 1),
  379.        substr(s.audit$, 17, 1) || '/' || substr(s.audit$, 18, 1),
  380.        substr(s.audit$, 19, 1) || '/' || substr(s.audit$, 20, 1),
  381.        substr(s.audit$, 21, 1) || '/' || substr(s.audit$, 22, 1),
  382.        substr(s.audit$, 23, 1) || '/' || substr(s.audit$, 24, 1),
  383.        substr(s.audit$, 25, 1) || '/' || substr(s.audit$, 26, 1)
  384. from sys.obj$ o, sys.seq$ s
  385. where o.type = 6
  386.   and o.owner# = userenv('SCHEMAID')
  387.   and o.obj# = s.obj#
  388. union all
  389. select o.name, 'PROCEDURE',
  390.        substr(p.audit$, 1, 1) || '/' || substr(p.audit$, 2, 1),
  391.        substr(p.audit$, 3, 1) || '/' || substr(p.audit$, 4, 1),
  392.        substr(p.audit$, 5, 1) || '/' || substr(p.audit$, 6, 1),
  393.        substr(p.audit$, 7, 1) || '/' || substr(p.audit$, 8, 1),
  394.        substr(p.audit$, 9, 1) || '/' || substr(p.audit$, 10, 1),
  395.        substr(p.audit$, 11, 1) || '/' || substr(p.audit$, 12, 1),
  396.        substr(p.audit$, 13, 1) || '/' || substr(p.audit$, 14, 1),
  397.        substr(p.audit$, 15, 1) || '/' || substr(p.audit$, 16, 1),
  398.        substr(p.audit$, 17, 1) || '/' || substr(p.audit$, 18, 1),
  399.        substr(p.audit$, 19, 1) || '/' || substr(p.audit$, 20, 1),
  400.        substr(p.audit$, 21, 1) || '/' || substr(p.audit$, 22, 1),
  401.        substr(p.audit$, 23, 1) || '/' || substr(p.audit$, 24, 1),
  402.        substr(p.audit$, 25, 1) || '/' || substr(p.audit$, 26, 1)
  403. from sys.obj$ o, sys.procedure$ p
  404. where o.type >= 7 and o.type <= 9
  405.   and o.owner# = userenv('SCHEMAID')
  406.   and o.obj# = p.obj#
  407. /
  408. comment on table USER_OBJ_AUDIT_OPTS is
  409. 'Auditing options for user''s own tables and views'
  410. /
  411. comment on column USER_OBJ_AUDIT_OPTS.OBJECT_NAME is
  412. 'Name of the object'
  413. /
  414. comment on column USER_OBJ_AUDIT_OPTS.OBJECT_TYPE is
  415. 'Type of the object:  "TABLE" or "VIEW"'
  416. /
  417. comment on column USER_OBJ_AUDIT_OPTS.ALT is
  418. 'Auditing ALTER WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  419. /
  420. comment on column USER_OBJ_AUDIT_OPTS.AUD is
  421. 'Auditing AUDIT WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  422. /
  423. comment on column USER_OBJ_AUDIT_OPTS.COM is
  424. 'Auditing COMMENT WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  425. /
  426. comment on column USER_OBJ_AUDIT_OPTS.DEL is
  427. 'Auditing DELETE WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  428. /
  429. comment on column USER_OBJ_AUDIT_OPTS.GRA is
  430. 'Auditing GRANT WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  431. /
  432. comment on column USER_OBJ_AUDIT_OPTS.IND is
  433. 'Auditing INDEX WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  434. /
  435. comment on column USER_OBJ_AUDIT_OPTS.INS is
  436. 'Auditing INSERT WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  437. /
  438. comment on column USER_OBJ_AUDIT_OPTS.LOC is
  439. 'Auditing LOCK WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  440. /
  441. comment on column USER_OBJ_AUDIT_OPTS.REN is
  442. 'Auditing RENAME WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  443. /
  444. comment on column USER_OBJ_AUDIT_OPTS.SEL is
  445. 'Auditing SELECT WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  446. /
  447. comment on column USER_OBJ_AUDIT_OPTS.UPD is
  448. 'Auditing UPDATE WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  449. /
  450. comment on column USER_OBJ_AUDIT_OPTS.REF is
  451. 'Auditing REFERENCE WHENEVER SUCCESSFUL / UNSUCCESSFUL (no used)'
  452. /
  453. comment on column USER_OBJ_AUDIT_OPTS.EXE is
  454. 'Auditing EXECUTE WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  455. /
  456. drop public synonym USER_OBJ_AUDIT_OPTS
  457. /
  458. create public synonym USER_OBJ_AUDIT_OPTS for USER_OBJ_AUDIT_OPTS
  459. /
  460. grant select on USER_OBJ_AUDIT_OPTS to PUBLIC
  461. /
  462. create or replace view DBA_OBJ_AUDIT_OPTS 
  463.     (OWNER,
  464.      OBJECT_NAME, 
  465.      OBJECT_TYPE, 
  466.      ALT,
  467.          AUD,
  468.          COM,
  469.          DEL,
  470.           GRA,
  471.           IND,
  472.          INS,
  473.          LOC,
  474.          REN,
  475.          SEL,
  476.          UPD,
  477.          REF,
  478.      EXE)
  479. as
  480. select u.name, o.name, 'TABLE',
  481.        substr(t.audit$, 1, 1) || '/' || substr(t.audit$, 2, 1),
  482.        substr(t.audit$, 3, 1) || '/' || substr(t.audit$, 4, 1),
  483.        substr(t.audit$, 5, 1) || '/' || substr(t.audit$, 6, 1),
  484.        substr(t.audit$, 7, 1) || '/' || substr(t.audit$, 8, 1),
  485.        substr(t.audit$, 9, 1) || '/' || substr(t.audit$, 10, 1),
  486.        substr(t.audit$, 11, 1) || '/' || substr(t.audit$, 12, 1),
  487.        substr(t.audit$, 13, 1) || '/' || substr(t.audit$, 14, 1),
  488.        substr(t.audit$, 15, 1) || '/' || substr(t.audit$, 16, 1),
  489.        substr(t.audit$, 17, 1) || '/' || substr(t.audit$, 18, 1),
  490.        substr(t.audit$, 19, 1) || '/' || substr(t.audit$, 20, 1),
  491.        substr(t.audit$, 21, 1) || '/' || substr(t.audit$, 22, 1),
  492.        substr(t.audit$, 23, 1) || '/' || substr(t.audit$, 24, 1),
  493.        substr(t.audit$, 25, 1) || '/' || substr(t.audit$, 26, 1)
  494. from sys.obj$ o, sys.user$ u, sys.tab$ t
  495. where o.type = 2
  496.   and not (o.owner# = 0 and o.name = '_default_auditing_options_')
  497.   and o.owner# = u.user#
  498.   and o.obj# = t.obj#
  499. union all
  500. select u.name, o.name, 'VIEW',
  501.        substr(v.audit$, 1, 1) || '/' || substr(v.audit$, 2, 1),
  502.        substr(v.audit$, 3, 1) || '/' || substr(v.audit$, 4, 1),
  503.        substr(v.audit$, 5, 1) || '/' || substr(v.audit$, 6, 1),
  504.        substr(v.audit$, 7, 1) || '/' || substr(v.audit$, 8, 1),
  505.        substr(v.audit$, 9, 1) || '/' || substr(v.audit$, 10, 1),
  506.        substr(v.audit$, 11, 1) || '/' || substr(v.audit$, 12, 1),
  507.        substr(v.audit$, 13, 1) || '/' || substr(v.audit$, 14, 1),
  508.        substr(v.audit$, 15, 1) || '/' || substr(v.audit$, 16, 1),
  509.        substr(v.audit$, 17, 1) || '/' || substr(v.audit$, 18, 1),
  510.        substr(v.audit$, 19, 1) || '/' || substr(v.audit$, 20, 1),
  511.        substr(v.audit$, 21, 1) || '/' || substr(v.audit$, 22, 1),
  512.        substr(v.audit$, 23, 1) || '/' || substr(v.audit$, 24, 1),
  513.        substr(v.audit$, 25, 1) || '/' || substr(v.audit$, 26, 1)
  514. from sys.obj$ o, sys.user$ u, sys.view$ v
  515. where o.type = 4
  516.   and o.owner# = u.user#
  517.   and o.obj# = v.obj#
  518. union all
  519. select u.name, o.name, 'SEQUENCE',
  520.        substr(s.audit$, 1, 1) || '/' || substr(s.audit$, 2, 1),
  521.        substr(s.audit$, 3, 1) || '/' || substr(s.audit$, 4, 1),
  522.        substr(s.audit$, 5, 1) || '/' || substr(s.audit$, 6, 1),
  523.        substr(s.audit$, 7, 1) || '/' || substr(s.audit$, 8, 1),
  524.        substr(s.audit$, 9, 1) || '/' || substr(s.audit$, 10, 1),
  525.        substr(s.audit$, 11, 1) || '/' || substr(s.audit$, 12, 1),
  526.        substr(s.audit$, 13, 1) || '/' || substr(s.audit$, 14, 1),
  527.        substr(s.audit$, 15, 1) || '/' || substr(s.audit$, 16, 1),
  528.        substr(s.audit$, 17, 1) || '/' || substr(s.audit$, 18, 1),
  529.        substr(s.audit$, 19, 1) || '/' || substr(s.audit$, 20, 1),
  530.        substr(s.audit$, 21, 1) || '/' || substr(s.audit$, 22, 1),
  531.        substr(s.audit$, 23, 1) || '/' || substr(s.audit$, 24, 1),
  532.        substr(s.audit$, 25, 1) || '/' || substr(s.audit$, 26, 1)
  533. from sys.obj$ o, sys.user$ u, sys.seq$ s
  534. where o.type = 6
  535.   and o.owner# = u.user#
  536.   and o.obj# = s.obj#
  537. union all
  538. select u.name, o.name, 'PROCEDURE',
  539.        substr(p.audit$, 1, 1) || '/' || substr(p.audit$, 2, 1),
  540.        substr(p.audit$, 3, 1) || '/' || substr(p.audit$, 4, 1),
  541.        substr(p.audit$, 5, 1) || '/' || substr(p.audit$, 6, 1),
  542.        substr(p.audit$, 7, 1) || '/' || substr(p.audit$, 8, 1),
  543.        substr(p.audit$, 9, 1) || '/' || substr(p.audit$, 10, 1),
  544.        substr(p.audit$, 11, 1) || '/' || substr(p.audit$, 12, 1),
  545.        substr(p.audit$, 13, 1) || '/' || substr(p.audit$, 14, 1),
  546.        substr(p.audit$, 15, 1) || '/' || substr(p.audit$, 16, 1),
  547.        substr(p.audit$, 17, 1) || '/' || substr(p.audit$, 18, 1),
  548.        substr(p.audit$, 19, 1) || '/' || substr(p.audit$, 20, 1),
  549.        substr(p.audit$, 21, 1) || '/' || substr(p.audit$, 22, 1),
  550.        substr(p.audit$, 23, 1) || '/' || substr(p.audit$, 24, 1),
  551.        substr(p.audit$, 25, 1) || '/' || substr(p.audit$, 26, 1)
  552. from sys.obj$ o, sys.user$ u, sys.procedure$ p
  553. where o.type >= 7 and o.type <= 9
  554.   and o.owner# = u.user#
  555.   and o.obj# = p.obj#
  556. /
  557. comment on table DBA_OBJ_AUDIT_OPTS is
  558. 'Auditing options for all tables and views'
  559. /
  560. comment on column DBA_OBJ_AUDIT_OPTS.OWNER is
  561. 'Owner of the object'
  562. /
  563. comment on column DBA_OBJ_AUDIT_OPTS.OBJECT_NAME is
  564. 'Name of the object'
  565. /
  566. comment on column DBA_OBJ_AUDIT_OPTS.OBJECT_TYPE is
  567. 'Type of the object'
  568. /
  569. comment on column DBA_OBJ_AUDIT_OPTS.ALT is
  570. 'Auditing ALTER WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  571. /
  572. comment on column DBA_OBJ_AUDIT_OPTS.AUD is
  573. 'Auditing AUDIT WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  574. /
  575. comment on column DBA_OBJ_AUDIT_OPTS.COM is
  576. 'Auditing COMMENT WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  577. /
  578. comment on column DBA_OBJ_AUDIT_OPTS.DEL is
  579. 'Auditing DELETE WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  580. /
  581. comment on column DBA_OBJ_AUDIT_OPTS.GRA is
  582. 'Auditing GRANT WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  583. /
  584. comment on column DBA_OBJ_AUDIT_OPTS.IND is
  585. 'Auditing INDEX WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  586. /
  587. comment on column DBA_OBJ_AUDIT_OPTS.INS is
  588. 'Auditing INSERT WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  589. /
  590. comment on column DBA_OBJ_AUDIT_OPTS.LOC is
  591. 'Auditing LOCK WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  592. /
  593. comment on column DBA_OBJ_AUDIT_OPTS.REN is
  594. 'Auditing RENAME WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  595. /
  596. comment on column DBA_OBJ_AUDIT_OPTS.SEL is
  597. 'Auditing SELECT WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  598. /
  599. comment on column DBA_OBJ_AUDIT_OPTS.UPD is
  600. 'Auditing UPDATE WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  601. /
  602. comment on column DBA_OBJ_AUDIT_OPTS.REF is
  603. 'Auditing REFERENCE WHENEVER SUCCESSFUL / UNSUCCESSFUL (not used)'
  604. /
  605. comment on column DBA_OBJ_AUDIT_OPTS.EXE is
  606. 'Auditing EXE WHENEVER SUCCESSFUL / UNSUCCESSFUL'
  607. /
  608. remark
  609. remark  FAMILY "STMT_AUDIT_OPTS"
  610. remark  This view is only accessible to DBAs.
  611. remark  One row is kept for each system auditing option set system wide, or
  612. remark  for a particular user.
  613. create or replace view DBA_STMT_AUDIT_OPTS
  614.     (USER_NAME, 
  615.     AUDIT_OPTION, 
  616.     SUCCESS, 
  617.     FAILURE)
  618. as
  619. select decode(aud.user#, 1 /* System wide auditing*/, null, usr.name)
  620.             /* USER_NAME */,
  621.        aom.name        /* AUDIT_OPTION */,
  622.        decode(aud.success, 1, 'BY SESSION', 2, 'BY ACCESS', 'NOT SET')
  623.             /* SUCCESS */,
  624.        decode(aud.failure, 1, 'BY SESSION', 2, 'BY ACCESS', 'NOT SET')
  625.                         /* FAILURE */
  626. from sys.user$ usr, STMT_AUDIT_OPTION_MAP aom, sys.audit$ aud
  627. where aud.option# = aom.option#
  628.   and aud.user# = usr.user#
  629. /
  630. comment on table DBA_STMT_AUDIT_OPTS is
  631. 'Describes current system auditing options across the system and by user'
  632. /
  633. comment on column DBA_STMT_AUDIT_OPTS.USER_NAME is
  634. 'User name if by user auditing, else null for system wide auditing'
  635. /
  636. comment on column DBA_STMT_AUDIT_OPTS.AUDIT_OPTION is
  637. 'Name of the system auditing option'
  638. /
  639. comment on column DBA_STMT_AUDIT_OPTS.SUCCESS is
  640. 'Mode for WHENEVER SUCCESSFUL system auditing'
  641. /
  642. comment on column DBA_STMT_AUDIT_OPTS.FAILURE is
  643. 'Mode for WHENEVER NOT SUCCESSFUL system auditing'
  644. /
  645. remark
  646. remark  FAMILY "PRIV_AUDIT_OPTS"
  647. remark  This view is only accessible to DBAs.
  648. remark  One row is kept for each system privilegeauditing option set 
  649. remark  system wide, or for a particular user.
  650. create or replace view DBA_PRIV_AUDIT_OPTS
  651.     (USER_NAME, 
  652.     PRIVILEGE, 
  653.     SUCCESS, 
  654.     FAILURE)
  655. as
  656. select decode(aud.user#, 1 /* System wide auditing*/, null, usr.name)
  657.             /* USER_NAME */,
  658.        prv.name        /* PRIVILEGE */,
  659.        decode(aud.success, 1, 'BY SESSION', 2, 'BY ACCESS', 'NOT SET')
  660.             /* SUCCESS */,
  661.        decode(aud.failure, 1, 'BY SESSION', 2, 'BY ACCESS', 'NOT SET')
  662.                         /* FAILURE */
  663. from sys.user$ usr, system_privilege_map prv, sys.audit$ aud
  664. where aud.option# = -prv.privilege
  665.   and aud.user# = usr.user#
  666. /
  667. comment on table DBA_PRIV_AUDIT_OPTS is
  668. 'Describes current system privileges being audited across the system and by user'
  669. /
  670. comment on column DBA_PRIV_AUDIT_OPTS.USER_NAME is
  671. 'User name if by user auditing, else null for system wide auditing'
  672. /
  673. comment on column DBA_PRIV_AUDIT_OPTS.PRIVILEGE is
  674. 'Name of the system privilege being audited'
  675. /
  676. comment on column DBA_PRIV_AUDIT_OPTS.SUCCESS is
  677. 'Mode for WHENEVER SUCCESSFUL system auditing'
  678. /
  679. comment on column DBA_PRIV_AUDIT_OPTS.FAILURE is
  680. 'Mode for WHENEVER NOT SUCCESSFUL system auditing'
  681. /
  682.  
  683. remark
  684. remark  FAMILY "AUDIT_TRAIL"
  685. remark  DBA_AUDIT_TRAIL 
  686. remark  The raw audit trail of all audit trail records in the system. Some
  687. remark  columns are only filled in by certain statements. This view isis 
  688. remark  accessible only to dba's.
  689. remark
  690. remark  USER_AUDIT_TRAIL
  691. remark  The raw audit trail of all information related to the user
  692. remark  or the objects owned by the user.  Some columns are only filled
  693. remark  in by certain statements. This view is created by selecting from
  694. remark  the DBA_AUDIT_TRAIL view, and retricting the rows.
  695. remark
  696. create or replace view DBA_AUDIT_TRAIL
  697.         (
  698.          OS_USERNAME, 
  699.      USERNAME,
  700.      USERHOST,
  701.      TERMINAL,
  702.      TIMESTAMP,
  703.      OWNER,
  704.      OBJ_NAME,
  705.      ACTION,
  706.      ACTION_NAME,
  707.          NEW_OWNER,
  708.      NEW_NAME,
  709.      OBJ_PRIVILEGE,
  710.      SYS_PRIVILEGE,
  711.      ADMIN_OPTION,
  712.      GRANTEE,
  713.      AUDIT_OPTION,
  714.      SES_ACTIONS,
  715.      LOGOFF_TIME,
  716.      LOGOFF_LREAD,
  717.      LOGOFF_PREAD,
  718.      LOGOFF_LWRITE,
  719.      LOGOFF_DLOCK,
  720.      COMMENT_TEXT,
  721.      SESSIONID,
  722.      ENTRYID,
  723.      STATEMENTID,
  724.      RETURNCODE,
  725.          PRIV_USED,
  726.          OBJECT_LABEL,
  727.          SESSION_LABEL
  728.     )
  729. as
  730. select spare1         /* OS_USERNAME */,
  731.        userid         /* USERNAME */,
  732.        userhost        /* USERHOST */,
  733.        terminal        /* TERMINAL */,
  734.        timestamp    /* TIMESTAMP */,
  735.        obj$creator     /* OWNER */,
  736.        obj$name        /* OBJECT_NAME */,
  737.        aud.action    /* ACTION */,
  738.        act.name        /* ACTION_NAME */,
  739.        new$owner        /* NEW_OWNER */,
  740.        new$name        /* NEW_NAME */,
  741.        decode(aud.action, 
  742.           108 /* grant  sys_priv */, null, 
  743.           109 /* revoke sys_priv */, null, 
  744.           114 /* grant  role */, null, 
  745.           115 /* revoke role */, null,
  746.           auth$privileges)  
  747.             /* OBJ_PRIVILEGE */,
  748.        decode(aud.action, 
  749.           108 /* grant  sys_priv */, spm.name, 
  750.           109 /* revoke sys_priv */, spm.name, 
  751.           null)
  752.             /* SYS_PRIVILEGE */,
  753.        decode(aud.action, 
  754.           108 /* grant  sys_priv */, substr(auth$privileges,1,1), 
  755.           109 /* revoke sys_priv */, substr(auth$privileges,1,1), 
  756.           114 /* grant  role */, substr(auth$privileges,1,1),
  757.           115 /* revoke role */, substr(auth$privileges,1,1), 
  758.           null)
  759.             /* ADMIN_OPTION */,
  760.        auth$grantee     /* GRANTEE */,
  761.        decode(aud.action,
  762.           104 /* audit   */, aom.name,
  763.           105 /* noaudit */, aom.name,
  764.           null)
  765.             /* AUDIT_OPTION  */,
  766.        ses$actions    /* SES_ACTIONS   */,
  767.        logoff$time     /* LOGOFF_TIME   */,
  768.        logoff$lread    /* LOGOFF_LREAD  */,
  769.        logoff$pread    /* LOGOFF_PREAD  */,
  770.        logoff$lwrite    /* LOGOFF_LWRITE */,
  771.        decode(aud.action,
  772.           104 /* audit   */, null,
  773.               105 /* noaudit */, null,
  774.           108 /* grant  sys_priv */, null, 
  775.           109 /* revoke sys_priv */, null,
  776.           114 /* grant  role */, null,
  777.           115 /* revoke role */, null,
  778.           aud.logoff$dead)
  779.              /* LOGOFF_DLOCK */,
  780.        comment$text      /* COMMENT_TEXT */,
  781.        sessionid     /* SESSIONID */,
  782.        entryid         /* ENTRYID */,
  783.        statement     /* STATEMENTID */,
  784.        returncode     /* RETURNCODE */,
  785.        spx.name          /* PRIVILEGE */,
  786.        rawtolab(obj$label)         /* OBJECT_LABEL */,
  787.        rawtolab(ses$label)         /* SESSION_LABEL */
  788. from sys.aud$ aud, system_privilege_map spm, system_privilege_map spx,
  789.      STMT_AUDIT_OPTION_MAP aom, audit_actions act
  790. where   aud.action      = act.action    (+)
  791.   and - aud.logoff$dead = spm.privilege (+)
  792.   and   aud.logoff$dead = aom.option#   (+)
  793.   and - aud.priv$used   = spx.privilege (+)
  794. /
  795. comment on table DBA_AUDIT_TRAIL is
  796. 'All audit trail entries'
  797. /
  798. comment on column DBA_AUDIT_TRAIL.OS_USERNAME is
  799. 'Operating System logon user name of the user whose actions were audited'
  800. /
  801. comment on column DBA_AUDIT_TRAIL.USERNAME is
  802. 'Name (not ID number) of the user whose actions were audited'
  803. /
  804. comment on column DBA_AUDIT_TRAIL.USERHOST is
  805. 'Numeric instance ID for the Oracle instance from which the user is accessing the database.  Used only in environments with distributed file systems and shared database files (e.g., clustered Oracle on DEC VAX/VMS clusters)'
  806. /
  807. comment on column DBA_AUDIT_TRAIL.TERMINAL is
  808. 'Identifier for the user''s terminal'
  809. /
  810. comment on column DBA_AUDIT_TRAIL.TIMESTAMP is
  811. 'Timestamp for the creation of the audit trail entry (Timestamp for the user''s logon for entries created by AUDIT SESSION)'
  812. /
  813. comment on column DBA_AUDIT_TRAIL.OWNER is
  814. 'Creator of object affected by the action'
  815. /
  816. comment on column DBA_AUDIT_TRAIL.OBJ_NAME is
  817. 'Name of the object affected by the action'
  818. /
  819. comment on column DBA_AUDIT_TRAIL.ACTION is
  820. 'Numeric action type code.  The corresponding name of the action type (CREATE TABLE, INSERT, etc.) is in the column ACTION_NAME'
  821. /
  822. comment on column DBA_AUDIT_TRAIL.ACTION_NAME is
  823. 'Name of the action type corresponding to the numeric code in ACTION'
  824. /
  825. comment on column DBA_AUDIT_TRAIL.NEW_OWNER is
  826. 'The owner of the object named in the NEW_NAME column'
  827. /
  828. comment on column DBA_AUDIT_TRAIL.NEW_NAME is
  829. 'New name of object after RENAME, or name of underlying object (e.g. CREATE INDEX owner.obj_name ON new_owner.new_name)'
  830. /
  831. comment on column DBA_AUDIT_TRAIL.OBJ_PRIVILEGE is
  832. 'Object privileges granted/revoked by a GRANT/REVOKE statement'
  833. /
  834. remark  There is one audit entry for each system privilege
  835. /
  836. comment on column DBA_AUDIT_TRAIL.SYS_PRIVILEGE is
  837. 'System privileges granted/revoked by a GRANT/REVOKE statement'
  838. /
  839. comment on column DBA_AUDIT_TRAIL.ADMIN_OPTION is
  840. 'If role/sys_priv was granted WITH ADMIN OPTON, A/-'
  841. /
  842. remark  There is one audit entry for each grantee.
  843. /
  844. comment on column DBA_AUDIT_TRAIL.GRANTEE is
  845. 'The name of the grantee specified in a GRANT/REVOKE statement'
  846. /
  847. remark  There is one audit entry for each system audit option
  848. /
  849. comment on column DBA_AUDIT_TRAIL.AUDIT_OPTION is
  850. 'Auditing option set with the audit statement'
  851. /
  852. comment on column DBA_AUDIT_TRAIL.SES_ACTIONS is
  853. 'Session summary.  A string of 11 characters, one for each action type, in thisorder: Alter, Audit, Comment, Delete, Grant, Index, Insert, Lock, Rename, Select, Update.  Values:  "-" = None, "S" = Success, "F" = Failure, "B" = Both'
  854. /
  855. remark  A single audit entry describes both the logon and logoff.
  856. remark  The logoff_* columns are null while a user is logged in.
  857. /
  858. comment on column DBA_AUDIT_TRAIL.LOGOFF_TIME is
  859. 'Timestamp for user logoff'
  860. /
  861. comment on column DBA_AUDIT_TRAIL.LOGOFF_LREAD is
  862. 'Logical reads for the session'
  863. /
  864. comment on column DBA_AUDIT_TRAIL.LOGOFF_PREAD is
  865. 'Physical reads for the session'
  866. /
  867. comment on column DBA_AUDIT_TRAIL.LOGOFF_LWRITE is
  868. 'Logical writes for the session'
  869. /
  870. comment on column DBA_AUDIT_TRAIL.LOGOFF_DLOCK is
  871. 'Deadlocks detected during the session'
  872. /
  873. comment on column DBA_AUDIT_TRAIL.COMMENT_TEXT is
  874. 'Text comment on the audit trail entry'
  875. /
  876. comment on column DBA_AUDIT_TRAIL.SESSIONID is
  877. 'Numeric ID for each Oracle session'
  878. /
  879. comment on column DBA_AUDIT_TRAIL.ENTRYID is
  880. 'Numeric ID for each audit trail entry in the session'
  881. /
  882. comment on column DBA_AUDIT_TRAIL.STATEMENTID is
  883. 'Numeric ID for each statement run (a statement may cause many actions)'
  884. /
  885. comment on column DBA_AUDIT_TRAIL.RETURNCODE is
  886. 'Oracle error code generated by the action.  Zero if the action succeeded'
  887. /
  888. comment on column DBA_AUDIT_TRAIL.PRIV_USED is
  889. 'System privilege used to execute the action'
  890. /
  891. comment on column DBA_AUDIT_TRAIL.OBJECT_LABEL is
  892. 'Optional Trusted ORACLE label associated with object being audited'
  893. /
  894. comment on column DBA_AUDIT_TRAIL.SESSION_LABEL is
  895. 'Trusted ORACLE label associated with user session'
  896. /
  897. create or replace view USER_AUDIT_TRAIL 
  898.         (
  899.          OS_USERNAME, 
  900.      USERNAME,
  901.      USERHOST,
  902.      TERMINAL,
  903.      TIMESTAMP,
  904.      OWNER,
  905.      OBJ_NAME,
  906.      ACTION,
  907.      ACTION_NAME,
  908.          NEW_OWNER,
  909.      NEW_NAME,
  910.      OBJ_PRIVILEGE,
  911.      SYS_PRIVILEGE,
  912.      ADMIN_OPTION,
  913.      GRANTEE,
  914.      AUDIT_OPTION,
  915.      SES_ACTIONS,
  916.      LOGOFF_TIME,
  917.      LOGOFF_LREAD,
  918.      LOGOFF_PREAD,
  919.      LOGOFF_LWRITE,
  920.      LOGOFF_DLOCK,
  921.      COMMENT_TEXT,
  922.      SESSIONID,
  923.      ENTRYID,
  924.      STATEMENTID,
  925.      RETURNCODE,
  926.          PRIV_USED,
  927.          OBJECT_LABEL,
  928.          SESSION_LABEL
  929.     )
  930. as
  931. select * from dba_audit_trail
  932. where ((owner = user) 
  933.     or (owner is null and username = user)) 
  934. /
  935. comment on table USER_AUDIT_TRAIL is
  936. 'Audit trail entries relevant to the user'
  937. /
  938. comment on column USER_AUDIT_TRAIL.OS_USERNAME is
  939. 'Operating System logon user name of the user whose actions were audited'
  940. /
  941. comment on column USER_AUDIT_TRAIL.USERNAME is
  942. 'Name (not ID number) of the user whose actions were audited'
  943. /
  944. comment on column USER_AUDIT_TRAIL.USERHOST is
  945. 'Numeric instance ID for the Oracle instance from which the user is accessing the database.  Used only in environments with distributed file systems and shared database files (e.g., clustered Oracle on DEC VAX/VMS clusters)'
  946. /
  947. comment on column USER_AUDIT_TRAIL.TERMINAL is
  948. 'Identifier for the user''s terminal'
  949. /
  950. comment on column USER_AUDIT_TRAIL.TIMESTAMP is
  951. 'Timestamp for the creation of the audit trail entry (Timestamp for the user''s logon for entries created by AUDIT SESSION)'
  952. /
  953. comment on column USER_AUDIT_TRAIL.OWNER is
  954. 'Creator of object affected by the action'
  955. /
  956. comment on column USER_AUDIT_TRAIL.OBJ_NAME is
  957. 'Name of the object affected by the action'
  958. /
  959. comment on column USER_AUDIT_TRAIL.ACTION is
  960. 'Numeric action type code.  The corresponding name of the action type (CREATE TABLE, INSERT, etc.) is in the column ACTION_NAME'
  961. /
  962. comment on column USER_AUDIT_TRAIL.ACTION_NAME is
  963. 'Name of the action type corresponding to the numeric code in ACTION'
  964. /
  965. comment on column USER_AUDIT_TRAIL.NEW_OWNER is
  966. 'The owner of the object named in the NEW_NAME column'
  967. /
  968. comment on column USER_AUDIT_TRAIL.NEW_NAME is
  969. 'New name of object after RENAME, or name of underlying object (e.g. CREATE INDEX owner.obj_name ON new_owner.new_name)'
  970. /
  971. comment on column USER_AUDIT_TRAIL.OBJ_PRIVILEGE is
  972. 'Object privileges granted/revoked by a GRANT/REVOKE statement'
  973. /
  974. remark  There is one audit entry for each system privilege
  975. /
  976. comment on column USER_AUDIT_TRAIL.SYS_PRIVILEGE is
  977. 'System privileges granted/revoked by a GRANT/REVOKE statement'
  978. /
  979. comment on column USER_AUDIT_TRAIL.ADMIN_OPTION is
  980. 'If role/sys_priv was granted WITH ADMIN OPTON, A/-'
  981. /
  982. remark  There is one audit entry for each grantee.
  983. /
  984. comment on column USER_AUDIT_TRAIL.GRANTEE is
  985. 'The name of the grantee specified in a GRANT/REVOKE statement'
  986. /
  987. remark  There is one audit entry for each system audit option
  988. /
  989. comment on column USER_AUDIT_TRAIL.AUDIT_OPTION is
  990. 'Auditing option set with the audit statement'
  991. /
  992. comment on column USER_AUDIT_TRAIL.SES_ACTIONS is
  993. 'Session summary.  A string of 11 characters, one for each action type, in thisorder: Alter, Audit, Comment, Delete, Grant, Index, Insert, Lock, Rename, Select, Update.  Values:  "-" = None, "S" = Success, "F" = Failure, "B" = Both'
  994. /
  995. remark  A single audit entry describes both the logon and logoff.
  996. remark  The logoff_* columns are null while a user is logged in.
  997. /
  998. comment on column USER_AUDIT_TRAIL.LOGOFF_TIME is
  999. 'Timestamp for user logoff'
  1000. /
  1001. comment on column USER_AUDIT_TRAIL.LOGOFF_LREAD is
  1002. 'Logical reads for the session'
  1003. /
  1004. comment on column USER_AUDIT_TRAIL.LOGOFF_PREAD is
  1005. 'Physical reads for the session'
  1006. /
  1007. comment on column USER_AUDIT_TRAIL.LOGOFF_LWRITE is
  1008. 'Logical writes for the session'
  1009. /
  1010. comment on column USER_AUDIT_TRAIL.LOGOFF_DLOCK is
  1011. 'Deadlocks detected during the session'
  1012. /
  1013. comment on column USER_AUDIT_TRAIL.COMMENT_TEXT is
  1014. 'Text comment on the audit trail entry'
  1015. /
  1016. comment on column USER_AUDIT_TRAIL.SESSIONID is
  1017. 'Numeric ID for each Oracle session'
  1018. /
  1019. comment on column USER_AUDIT_TRAIL.ENTRYID is
  1020. 'Numeric ID for each audit trail entry in the session'
  1021. /
  1022. comment on column USER_AUDIT_TRAIL.STATEMENTID is
  1023. 'Numeric ID for each statement run (a statement may cause many actions)'
  1024. /
  1025. comment on column USER_AUDIT_TRAIL.RETURNCODE is
  1026. 'Oracle error code generated by the action.  Zero if the action succeeded'
  1027. /
  1028. comment on column USER_AUDIT_TRAIL.PRIV_USED is
  1029. 'System privilege used to execute the action'
  1030. /
  1031. comment on column USER_AUDIT_TRAIL.OBJECT_LABEL is
  1032. 'Optional Trusted ORACLE label associated with object being audited'
  1033. /
  1034. comment on column USER_AUDIT_TRAIL.SESSION_LABEL is
  1035. 'Trusted ORACLE label associated with user session'
  1036. /
  1037. drop public synonym USER_AUDIT_TRAIL
  1038. /
  1039. create public synonym USER_AUDIT_TRAIL for USER_AUDIT_TRAIL
  1040. /
  1041. grant select on USER_AUDIT_TRAIL to public
  1042. /
  1043. remark 
  1044. remark  FAMILY "AUDIT_SESSION"
  1045. remark
  1046. remark  DBA_AUDIT_SESSION
  1047. remark  All audit trail records concerning connect and disconnect, based
  1048. remark  DBA_AUDIT_TRAIL.
  1049. remark
  1050. remark  USER_AUDIT_SESSION
  1051. remark  All audit trail records concerning connect and disconnect, based
  1052. remark  USER_AUDIT_TRAIL.
  1053. remark
  1054.  
  1055.  
  1056. create or replace view DBA_AUDIT_SESSION
  1057. as
  1058. select os_username, username, userhost, terminal, timestamp, action_name,
  1059.        logoff_time, logoff_lread, logoff_pread, logoff_lwrite, logoff_dlock,
  1060.        sessionid, returncode, session_label
  1061. from dba_audit_trail
  1062. where action between 100 and 102
  1063. /
  1064.  
  1065. create or replace view USER_AUDIT_SESSION
  1066. as
  1067. select os_username, username, userhost, terminal, timestamp, action_name,
  1068.        logoff_time, logoff_lread, logoff_pread, logoff_lwrite, logoff_dlock,
  1069.        sessionid, returncode, session_label
  1070. from user_audit_trail 
  1071. where action between 100 and 102
  1072. /
  1073. drop public synonym USER_AUDIT_SESSION
  1074. /
  1075. create public synonym USER_AUDIT_SESSION for USER_AUDIT_SESSION
  1076. /
  1077. grant select on USER_AUDIT_SESSION to public
  1078. /
  1079.  
  1080. remark
  1081. remark  FAMILY "AUDIT_STATEMENT"
  1082. remark
  1083. remark  DBA_AUDIT_STATEMENT
  1084. remark  All audit trail records concerning the following statements:
  1085. remark  grant, revoke, audit, noaudit and alter system.
  1086. remark  Based on DBA_AUDIT_TRAIL.
  1087. remark  
  1088. remark  USER_AUDIT_STATEMENT
  1089. remark  Same as the DBA version, except it is based on USER_AUDIT_TRAIL.
  1090. remark
  1091.  
  1092. create or replace view DBA_AUDIT_STATEMENT
  1093. as
  1094. select OS_USERNAME, USERNAME, USERHOST, TERMINAL, TIMESTAMP,
  1095.        OWNER, OBJ_NAME, ACTION_NAME, NEW_NAME, 
  1096.        OBJ_PRIVILEGE, SYS_PRIVILEGE, ADMIN_OPTION, GRANTEE, AUDIT_OPTION,
  1097.        SES_ACTIONS, COMMENT_TEXT, SESSIONID, ENTRYID, STATEMENTID,
  1098.        RETURNCODE, PRIV_USED, SESSION_LABEL
  1099. from dba_audit_trail
  1100. where action in (      17 /* GRANT OBJECT  */, 
  1101.              18 /* REVOKE OBJECT */, 
  1102.              30 /* AUDIT OBJECT */,
  1103.              31 /* NOAUDIT OBJECT */,
  1104.              49 /* ALTER SYSTEM */,
  1105.             104 /* SYSTEM AUDIT */,
  1106.             105 /* SYSTEM NOAUDIT */,
  1107.             106 /* AUDIT DEFAULT */,
  1108.             107 /* NOAUDIT DEFAULT */,
  1109.             108 /* SYSTEM GRANT */,
  1110.             109 /* SYSTEM REVOKE */,
  1111.             114 /* GRANT ROLE */,
  1112.             115 /* REVOKE ROLE */ ) 
  1113. /
  1114. comment on table DBA_AUDIT_STATEMENT is
  1115. 'Audit trail records concerning  grant, revoke, audit, noaudit and alter system'
  1116. /
  1117.  
  1118. create or replace view USER_AUDIT_STATEMENT
  1119. as
  1120. select OS_USERNAME, USERNAME, USERHOST, TERMINAL, TIMESTAMP,
  1121.        OWNER, OBJ_NAME, ACTION_NAME, NEW_NAME,
  1122.        OBJ_PRIVILEGE, SYS_PRIVILEGE, ADMIN_OPTION, GRANTEE, AUDIT_OPTION,
  1123.        SES_ACTIONS, COMMENT_TEXT, SESSIONID, ENTRYID, STATEMENTID,
  1124.        RETURNCODE, PRIV_USED, SESSION_LABEL
  1125. from user_audit_trail
  1126. where action in (      17 /* GRANT OBJECT  */, 
  1127.              18 /* REVOKE OBJECT */, 
  1128.              30 /* AUDIT OBJECT */,
  1129.              31 /* NOAUDIT OBJECT */,
  1130.              49 /* ALTER SYSTEM */,
  1131.             104 /* SYSTEM AUDIT */,
  1132.             105 /* SYSTEM NOAUDIT */,
  1133.             106 /* AUDIT DEFAULT */,
  1134.             107 /* NOAUDIT DEFAULT */,
  1135.             108 /* SYSTEM GRANT*/,
  1136.             109 /* SYSTEM REVOKE */,
  1137.             114 /* GRANT ROLE */,
  1138.             115 /* REVOKE ROLE */ ) 
  1139. /
  1140. comment on table USER_AUDIT_STATEMENT is
  1141. 'Audit trail records concerning  grant, revoke, audit, noaudit and alter system'
  1142. /
  1143. drop public synonym USER_AUDIT_STATEMENT
  1144. /
  1145. create public synonym USER_AUDIT_STATEMENT for USER_AUDIT_STATEMENT
  1146. /
  1147. grant select on USER_AUDIT_STATEMENT to public
  1148. /
  1149.  
  1150. remark
  1151. remark  FAMILY "AUDIT_OBJECT"
  1152. remark
  1153. remark  DBA_AUDIT_OBJECT
  1154. remark  Audit trail records for statements concerning objects, 
  1155. remark  specifically: table, cluster, view, index, sequence, 
  1156. remark  [public] database link, [public] synonym, procedure, trigger,
  1157. remark  rollback segment, tablespace, role, user. The audit trail 
  1158. remark  records for audit/noaudit and grant/revoke operations on these 
  1159. remark  objects can be seen through the dba_audit_statement view.
  1160. remark
  1161. remark  USER_AUDIT_OBJECT
  1162. remark  Same as DBA_AUDIT_OBJECT, except this is based on 
  1163. remark    DBA_AUDIT_TRAIL.
  1164. remark
  1165.  
  1166. create or replace view DBA_AUDIT_OBJECT
  1167. as
  1168. select OS_USERNAME, USERNAME, USERHOST, TERMINAL, TIMESTAMP,
  1169.        OWNER, OBJ_NAME, ACTION_NAME, NEW_OWNER, NEW_NAME, 
  1170.        SES_ACTIONS, COMMENT_TEXT, SESSIONID, ENTRYID, STATEMENTID,
  1171.        RETURNCODE, PRIV_USED, OBJECT_LABEL, SESSION_LABEL
  1172. from dba_audit_trail
  1173. where (action between 1 and 16)
  1174.    or (action between 19 and 29)
  1175.    or (action between 32 and 41)
  1176.    or (action = 43)
  1177.    or (action between 51 and 99)
  1178.    or (action = 103)
  1179.    or (action between 110 and 113)
  1180.    or (action between 116 and 121)
  1181. /
  1182. comment on table DBA_AUDIT_OBJECT is 
  1183. 'Audit trail records for statements concerning objects, specifically: table, cluster, view, index, sequence,  [public] database link, [public] synonym, procedure, trigger, rollback segment, tablespace, role, user'
  1184. /
  1185.  
  1186. create or replace view USER_AUDIT_OBJECT
  1187. as
  1188. select OS_USERNAME, USERNAME, USERHOST, TERMINAL, TIMESTAMP,
  1189.        OWNER, OBJ_NAME, ACTION_NAME, NEW_OWNER, NEW_NAME, 
  1190.        SES_ACTIONS, COMMENT_TEXT, SESSIONID, ENTRYID, STATEMENTID,
  1191.        RETURNCODE, PRIV_USED, OBJECT_LABEL, SESSION_LABEL
  1192. from user_audit_trail
  1193. where (action between 1 and 16)
  1194.    or (action between 19 and 29)
  1195.    or (action between 32 and 41)
  1196.    or (action = 43)
  1197.    or (action between 51 and 99)
  1198.    or (action = 103)
  1199.    or (action between 110 and 113)
  1200.    or (action between 116 and 121)
  1201. /
  1202. comment on table USER_AUDIT_OBJECT is 
  1203. 'Audit trail records for statements concerning objects, specifically: table, cluster, view, index, sequence,  [public] database link, [public] synonym, procedure, trigger, rollback segment, tablespace, role, user'
  1204. /
  1205. drop public synonym USER_AUDIT_OBJECT
  1206. /
  1207. create public synonym USER_AUDIT_OBJECT for USER_AUDIT_OBJECT
  1208. /
  1209. grant select on USER_AUDIT_OBJECT to public
  1210. /
  1211.  
  1212. remark
  1213. remark  DBA_AUDIT_EXISTS
  1214. remark  Only dba's can see audit info about objects that do not exist.
  1215. remark
  1216. remark  Lists audit trail entries produced by AUDIT EXISTS/NOT EXISTS.
  1217. remark  This is all audit trail entries with return codes of
  1218. remark  942, 943, 959, 1418, 1432, 1434, 1435, 1534, 1917, 1918, 1919,
  1219. remark  2019, 2024 and 2289 and for Trusted ORACLE 1, 951, 955, 957, 1430,
  1220. remark  1433, 1452, 1471, 1535, 1543, 1758, 1920, 1921, 1922, 2239, 2264,
  1221. remark  2266, 2273, 2292, 2297, 2378, 2379, 2382, 4081, 12006, 12325.
  1222. remark  This view is accessible to DBAs only.
  1223. remark
  1224. create or replace view DBA_AUDIT_EXISTS as
  1225.   select os_username, username, userhost, terminal, timestamp,
  1226.      owner, obj_name,
  1227.      action_name,
  1228.          new_owner,
  1229.      new_name,
  1230.      obj_privilege, sys_privilege, grantee,
  1231.      sessionid, entryid, statementid, returncode
  1232.   from dba_audit_trail
  1233.   where returncode in
  1234.   (942, 943, 959, 1418, 1432, 1434, 1435, 1534, 1917, 1918, 1919, 2019, 
  1235.    2024, 2289,
  1236.    4042, 4043, 4080, 1, 951, 955, 957, 1430, 1433, 1452, 1471, 1535, 1543,
  1237.    1758, 1920, 1921, 1922, 2239, 2264, 2266, 2273, 2292, 2297, 2378, 2379,
  1238.    2382, 4081, 12006, 12325)
  1239. /
  1240. comment on table DBA_AUDIT_EXISTS is
  1241. 'Lists audit trail entries produced by AUDIT NOT EXISTS and AUDIT EXISTS'
  1242. /
  1243.  
  1244.