home *** CD-ROM | disk | FTP | other *** search
/ Winzipper / Winzipper_ISO.iso / programming / oracle7 7.2 / DB / UTIL72 / CATAUDIT.SQL < prev    next >
Encoding:
Text File  |  1995-05-09  |  48.9 KB  |  1,277 lines

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