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

  1. rem 
  2. rem $Header: catalog.sql 7010300.2 94/04/04 02:35:41 snataraj Generic<base> $ catalog.sql
  3. rem 
  4. Rem Copyright (c) 1988 by Oracle Corporation
  5. Rem
  6. Rem NAME
  7. Rem   CATALOG.SQL
  8. Rem FUNCTION
  9. Rem   Creates data dictionary views.
  10. Rem NOTES
  11. Rem   Must be run when connected to SYS or INTERNAL.
  12. Rem
  13. Rem   Do not create DBA synonyms in this file, they should be
  14. Rem   added to the file dba_syn.sql
  15. Rem
  16. Rem Please make sure that the following 3 lines are at the end of this file:
  17. Rem ---------------------------------------------------------------------------
  18. Rem THIS IS THE END OF THIS FILE - IF I AM NOT HERE THEN RCS HAS TRUNCATED FILE
  19. Rem ---------------------------------------------------------------------------
  20. Rem MODIFIED
  21. Rem     thayes     03/02/94 -  Add compatibility views
  22. Rem     wmaimone   03/02/94 -  add view and public synonym for v$sess_io
  23. Rem     ltung      02/20/94 -  yet another parallel/cache semantic change
  24. Rem     ltung      01/23/94 -  add v$pq_sysstat
  25. Rem     ltung      01/19/94 -  add v$pq_sesstat and v$pq_slave
  26. Rem     ltung      01/15/94 -  new parallel/cache/partitions semantics
  27. Rem     agupta     01/05/94 -  192948 - change units for *_extents in *_segment
  28. Rem     jcohen     01/04/94 - #(192450) add v$option table
  29. Rem     jcohen     12/20/93 - #(191673) fix number fmt for user_tables,cluster
  30. Rem     jbellemo   11/09/93 -  #170173: change uid to userenv('schemaid')
  31. Rem     gdoherty   11/01/93 -  add call to catsvrmg for Server Manager
  32. Rem     gdoherty   10/20/93 -  add v$nls_valid_values
  33. Rem     hkodaval   10/14/93 -  merge changes from branch 1.151.312.7
  34. Rem     wbridge    07/02/93 -  add v$controlfile fixed table
  35. Rem     ltung      06/25/93 -  merge changes from branch 1.151.312.4
  36. Rem     jcohen     06/22/93 - #(165117) new view product_component_version
  37. Rem     vraghuna   06/17/93 -  bug 166480 - move resource_map into sql.bsq
  38. Rem     ltung      05/28/93 -  parallel/cache in table/cluster views
  39. Rem     wmaimone   05/20/93 -  merge changes from branch 1.151.312.3 
  40. Rem     wmaimone   05/20/93 -  merge changes from branch 1.151.312.1 
  41. Rem     jcohen     05/18/93 - #(163749) passwords visible in SYS.DBA_DB_LINKS
  42. Rem     wmaimone   05/18/93 -  fix width of all_indexes 
  43. Rem     ltung      05/14/93 - #(157449) add v$dblink 
  44. Rem     hkodaval   04/30/93 -  Bug 162360: free lists/groups should show > 0 
  45. Rem                             in views user_segments and dba_segments
  46. Rem     rnakhwa    04/12/93 -  merge changes from branch 1.151.312.2 
  47. Rem     wbridge    04/02/93 -  read-only tablespaces 
  48. Rem     agupta     01/10/93 -  141957 - remove divide by 0 window 
  49. Rem     wmaimone   05/07/93 -  #(161964) use system privs for all_* 
  50. Rem     rnakhwa    04/12/93 -  Embedded comments are not allowd within SQL stat
  51. Rem     wmaimone   04/02/93 -  #(158143) grant select on nls_parameters 
  52. Rem     wmaimone   04/02/93 -  #(158143) grant select on nls_parameters 
  53. Rem     ksriniva   11/30/92 -  add synonyms for v$session_event, v$system_event
  54. Rem     tpystyne   11/27/92 -  add nls_* views 
  55. Rem     ghallmar   11/20/92 -  fix DBA_2PC_PENDING.GLOBAL_TRAN_ID 
  56. Rem     amendels   11/19/92 -  fix 139681, 140003: modify *_constraints 
  57. Rem     ksriniva   11/13/92 -  add public synonym for v$session_wait 
  58. Rem     pritto     11/09/92 -  add synonym for V$MTS 
  59. Rem     tpystyne   11/06/92 -  use create or replace view 
  60. Rem     jklein     09/29/92 -  histogram support 
  61. Rem     vraghuna   10/29/92 -  bug 130560 - move map tables in sql.bsq 
  62. Rem     jloaiza    10/28/92 -  add v$db_object_cache and v$open_cursor 
  63. Rem     glumpkin   10/20/92 -  Adjust for new .sql filenames 
  64. Rem     ltan       10/20/92 -  rename DBA_ROLLBACK_SEGS status 
  65. Rem     mmoore     10/15/92 - #(134232) show more privs in all_tab_privs
  66. Rem     mmoore     10/15/92 - #(133927) speed up table_privileges view 
  67. Rem     dsdaniel   10/13/92 -  bug 112376 112374 125947 alter/create profile 
  68. Rem     amendels   10/08/92 -  132726: fix *_constraints to show DELETE CASCADE
  69. Rem     mmoore     10/08/92 - #(132956) remove _next_objects from dba_objects
  70. Rem     jwijaya    10/07/92 -  add v$*cursor_cache 
  71. Rem     ltan       10/07/92 -  fix undefined status for dba_rollback_segs
  72. Rem     mmoore     10/02/92 -  fix role_privs views 
  73. Rem     ltan       09/11/92 -  decode new status for rollback segment 
  74. Rem     jbellemo   09/24/92 -  merge changes from branch 1.124.311.2 
  75. Rem     jbellemo   09/18/92 -  #126685: show datatype 106 as MLSLABEL in *_TAB_
  76. Rem     mmoore     09/23/92 -  fix comment on dba_role_privs 
  77. Rem     aho        09/23/92 -  change view text to upper case & make shorter
  78. Rem     pritto     09/04/92 -  rename dispatcher view synonyms 
  79. Rem     jwijaya    09/09/92 -  add v$fixed_table 
  80. Rem     aho        08/31/92 -  merge forward status column in *_indexes from v6
  81. Rem                         -  bug 126268
  82. Rem     mmoore     08/28/92 - #(124859) add default role information to role vi
  83. Rem     mmoore     08/10/92 - #(121120) remove create index from system_priv_ma
  84. Rem     rjenkins   07/24/92 -  removing drop & alter snapshot 
  85. Rem     hrizvi     07/16/92 -  add v$license
  86. Rem     mmoore     07/13/92 - #(104081) change alter resource priv name -> add 
  87. Rem     agupta     06/26/92 -  115032 - add lists,groups to *_segments 
  88. Rem     wbridge    06/25/92 -  fixed tables for file headers 
  89. Rem     jwijaya    06/25/92 -  MODIFIED -> LAST_DDL_TIME per marketing 
  90. Rem     epeeler    06/23/92 -  accomodate new type 7 in cdef$ 
  91. Rem     jwijaya    06/15/92 -  v$plsarea is obsolete 
  92. Rem     jbellemo   06/12/92 -  add mapping for MLSLABEL to *_TAB_COLUMNS 
  93. Rem     jwijaya    06/04/92 -  fix a typo 
  94. Rem     mmoore     06/04/92 - #(112281) add execute to table_privs 
  95. Rem     agupta     06/01/92 -  111558 - user_tablespaces view wrong 
  96. Rem     mmoore     06/01/92 - #(111110) fix dba_role_privs
  97. Rem     rlim       05/29/92 -  #110883 - add missing views in dictionary 
  98. Rem     jwijaya    05/26/92 -  fix bug 110884 - don't grant on v$sga
  99. Rem     jwijaya    05/19/92 -  add v$type_size 
  100. Rem     rlim       05/15/92 -  fix bug 101589 - correct spelling mistakes 
  101. Rem     epeeler    05/06/92 -  fix NULL columns - bug 103146 
  102. Rem     mmoore     05/01/92 - #(107592) fix all_views to look at enabled roles 
  103. Rem     jwijaya    04/23/92 -  status for _NEXT_OBJECT is N/A
  104. Rem     agupta     04/16/92 -  add columns to dba_segments 
  105. Rem     mmoore     04/13/92 -  merge changes from branch 1.101.300.1 
  106. Rem     mmoore     03/03/92 -  change grant view names
  107. Rem     rnakhwa    03/10/92 -  + synonyms 4 views-v$thread, v$datafile, v$log
  108. Rem     thayes     03/24/92 -  Define v$rollname in catalog.sql instead of kqfv
  109. Rem     wmaimone   02/24/92 -  add v$mls_parameters 
  110. Rem     mmoore     02/19/92 -  remove more v$osroles 
  111. Rem     mmoore     02/19/92 -  remove v$enabledroles and v$osroles 
  112. Rem     jwijaya    02/06/92 -  add v$librarycache 
  113. Rem     mmoore     01/31/92 -  fix the user_free_space view 
  114. Rem     rkooi      01/23/92 -  drop global naming views before creating them 
  115. Rem     rkooi      01/23/92 -  use @@ command for subscripts 
  116. Rem     rkooi      01/18/92 -  add synonym 
  117. Rem     rkooi      01/18/92 -  add object_sizes views 
  118. Rem     rkooi      01/10/92 -  fix up trigger views 
  119. Rem     ajasuja    12/31/91 -  fix dba_audit_trail view 
  120. Rem     ajasuja    12/30/91 -  audit EXISTS 
  121. Rem     amendels   12/23/91 -  simplify *_clusters as clu$.hashkeys cannot be n
  122. Rem     amendels   12/23/91 -  fix *_clusters views for hashing 
  123. Rem     agupta     12/23/91 -  89036 - dba_ts_quotas 
  124. Rem     rkooi      12/15/91 -  change 'triggering_statement' to 'trigger_body' 
  125. Rem     ajasuja    11/27/91 -  add system privilege auditing 
  126. Rem     amendels   11/26/91 -  modify user/dba_clusters for hash cluster 
  127. Rem     ghallmar   11/08/91 -  add GLOBAL_NAME view 
  128. Rem     rjenkins   11/07/91 -  commenting snapshots 
  129. Rem     ltan       12/02/91 -  add inst# to undo$ 
  130. Rem     mroberts   10/30/91 -  apply error view changes (for views) to IMRG 
  131. Rem     rkooi      10/20/91 -  add public_dependency, fix priv checking
  132. Rem                            on all_objects
  133. Rem     smcadams   10/19/91 -  tweak audit_action table 
  134. Rem                            add execute obj audit option to audit views
  135. Rem                            add new_owner to dba_audit_trail
  136. Rem     mroberts   10/14/91 -  add v$nls_parameters view 
  137. Rem     mroberts   10/11/91 -  put VIEW changes in the mainline 
  138. Rem     jcleland   10/11/91 -  add mac privileges to sys_priv_map 
  139. Rem     epeeler    10/10/91 -  add enabled status columns to constraint views 
  140. Rem     cheigham   10/03/91 -  remove extra ;'s 
  141. Rem     mmoore     09/18/91 - #(74112) add dba_roles view to show all roles 
  142. Rem     agupta     09/03/91 -  add sequence# to tabauth$ 
  143. Rem     mmoore     09/03/91 -  change trigger view column names again 
  144. Rem     ghallmar   08/12/91 -  global naming 
  145. Rem     amendels   08/29/91 -  fix dict_columns: 'ALL$' -> 'ALL%'
  146. Rem     rlim       08/22/91 -  add comments regarding dba synonyms 
  147. Rem     mmoore     08/17/91 - #77458  change trigger views 
  148. Rem     mmoore     08/01/91 -  merge changes from branch 1.59.100.1 
  149. Rem     mmoore     08/01/91 -  move column_privileges back  
  150. Rem     rlim       07/31/91 -  added remarks column to syscatalog & catalog
  151. Rem     rlim       07/30/91 -  moved dba synonyms to dba_synonyms.sql 
  152. Rem     mmoore     07/22/91 - #65139  fix bug in user_tablespaces 
  153. Rem     jwijaya    07/14/91 -  remove unnecessary LINKNAME IS NULL
  154. Rem   mmoore     07/08/91 - change trigger view column names 
  155. Rem   amendels   07/02/91 - remove change to *_constraints.constraint_type
  156. Rem   mmoore     06/28/91 - move table_privileges back in 
  157. Rem   ltan       06/24/91 - bug 65188,add comment on DBA_ROLLBACK_SEGS.BLOCK_ID
  158. Rem   mmoore     06/24/91 - move table and column_privileges to catalog6
  159. Rem   ghallmar   06/11/91 -         new improved 2PC views 
  160. Rem   amendels   06/10/91 - move obsolete sql2 views to catalog6.sql;
  161. Rem                       - remove decodes for type 97;
  162. Rem                       - union -> union all;
  163. Rem                       - improve *_constraints.constraint_type (66063)
  164. Rem   mmoore     06/10/91 - add grantable column to privilege views
  165. Rem   smcadams   06/09/91 - add actions to audit_actions
  166. Rem   mmoore     06/03/91 - change user$ column names 
  167. Rem   agupta     06/07/91 - syntax error in exp_objects view 
  168. Rem   rkooi      10/22/91 - deleted lots of comments (co truncate bug)
  169. Rem   Grayson    03/21/88 - Creation
  170.  
  171. remark
  172. remark    FAMILY "FIXED (VIRTUAL) VIEWS"
  173. remark               
  174.  
  175. create or replace view v_$controlfile as select * from v$controlfile;
  176. drop public synonym v$controlfile;
  177. create public synonym v$controlfile for v_$controlfile;
  178.  
  179. create or replace view v_$datafile as select * from v$datafile;
  180. drop public synonym v$datafile;
  181. create public synonym v$datafile for v_$datafile;
  182.  
  183. create or replace view v_$log as select * from v$log;
  184. drop public synonym v$log;
  185. create public synonym v$log for v_$log;
  186.  
  187. create or replace view v_$thread as select * from v$thread;
  188. drop public synonym v$thread;
  189. create public synonym v$thread for v_$thread;
  190.  
  191. create or replace view v_$process as select * from v$process;
  192. drop public synonym v$process;
  193. create public synonym v$process for v_$process;
  194.  
  195. create or replace view v_$bgprocess as select * from v$bgprocess;
  196. drop public synonym v$bgprocess;
  197. create public synonym v$bgprocess for v_$bgprocess;
  198.  
  199. create or replace view v_$session as select * from v$session;
  200. drop public synonym v$session;
  201. create public synonym v$session for v_$session;
  202.  
  203. create or replace view v_$license as select * from v$license;
  204. drop public synonym v$license;
  205. create public synonym v$license for v_$license;
  206.  
  207. create or replace view v_$transaction as select * from v$transaction;
  208. drop public synonym v$transaction;
  209. create public synonym v$transaction for v_$transaction;
  210.  
  211. create or replace view v_$latch as select * from v$latch;
  212. drop public synonym v$latch;
  213. create public synonym v$latch for v_$latch;
  214.  
  215. create or replace view v_$latchname as select * from v$latchname;
  216. drop public synonym v$latchname;
  217. create public synonym v$latchname for v_$latchname;
  218.  
  219. create or replace view v_$latchholder as select * from v$latchholder;
  220. drop public synonym v$latchholder;
  221. create public synonym v$latchholder for v_$latchholder;
  222.  
  223. create or replace view v_$resource as select * from v$resource;
  224. drop public synonym v$resource;
  225. create public synonym v$resource for v_$resource;
  226.  
  227. create or replace view v_$_lock as select * from v$_lock;
  228. drop public synonym v$_lock;
  229. create public synonym v$_lock for v_$_lock;
  230.  
  231. create or replace view v_$lock as select * from v$lock;
  232. drop public synonym v$lock;
  233. create public synonym v$lock for v_$lock;
  234.  
  235. create or replace view v_$sesstat as select * from v$sesstat;
  236. drop public synonym v$sesstat;
  237. create public synonym v$sesstat for v_$sesstat;
  238.  
  239. create or replace view v_$sysstat as select * from v$sysstat;
  240. drop public synonym v$sysstat;
  241. create public synonym v$sysstat for v_$sysstat;
  242.  
  243. create or replace view v_$statname as select * from v$statname;
  244. drop public synonym v$statname;
  245. create public synonym v$statname for v_$statname;
  246.  
  247. create or replace view v_$access as select * from v$access;
  248. drop public synonym v$access;
  249. create public synonym v$access for v_$access;
  250.  
  251. create or replace view v_$dbfile as select * from v$dbfile;
  252. drop public synonym v$dbfile;
  253. create public synonym v$dbfile for v_$dbfile;
  254.  
  255. create or replace view v_$filestat as select * from v$filestat;
  256. drop public synonym v$filestat;
  257. create public synonym v$filestat for v_$filestat;
  258.  
  259. create or replace view v_$logfile as select * from v$logfile;
  260. drop public synonym v$logfile;
  261. create public synonym v$logfile for v_$logfile;
  262.  
  263. create or replace view v_$rollname as select x$kturd.kturdusn usn,undo$.name
  264.    from x$kturd, undo$
  265.    where x$kturd.kturdusn=undo$.us# and x$kturd.kturdsiz!=0;
  266. drop public synonym v$rollname;
  267. create public synonym v$rollname for v_$rollname;
  268.  
  269. create or replace view v_$rollstat as select * from v$rollstat;
  270. drop public synonym v$rollstat;
  271. create public synonym v$rollstat for v_$rollstat;
  272.  
  273. create or replace view v_$sga as select * from v$sga;
  274. drop public synonym v$sga;
  275. create public synonym v$sga for v_$sga;
  276.  
  277. create or replace view v_$parameter as select * from v$parameter;
  278. drop public synonym v$parameter;
  279. create public synonym v$parameter for v_$parameter;
  280.  
  281. create or replace view v_$rowcache as select * from v$rowcache;
  282. drop public synonym v$rowcache;
  283. create public synonym v$rowcache for v_$rowcache;
  284.  
  285. create or replace view v_$enabledprivs as select * from v$enabledprivs;
  286. drop public synonym v$enabledprivs;
  287. create public synonym v$enabledprivs for v_$enabledprivs;
  288.  
  289. create or replace view v_$nls_parameters as select * from v$nls_parameters;
  290. drop public synonym v$nls_parameters;
  291. create public synonym v$nls_parameters for v_$nls_parameters;
  292. grant select on v_$nls_parameters to public;
  293.  
  294. create or replace view v_$nls_valid_values as
  295. select * from v$nls_valid_values;
  296. drop public synonym v$nls_valid_values;
  297. create public synonym v$nls_valid_values for v_$nls_valid_values;
  298. grant select on v_$nls_valid_values to public;
  299.  
  300. create or replace view v_$mls_parameters as select * from v$parameter
  301. where name like 'mls%';
  302. drop public synonym v$mls_parameters;
  303. create public synonym v$mls_parameters for v_$mls_parameters;
  304. grant select on v_$mls_parameters to public;
  305.  
  306. create or replace view v_$librarycache as select * from v$librarycache;
  307. drop public synonym v$librarycache;
  308. create public synonym v$librarycache for v_$librarycache;
  309.  
  310. create or replace view v_$type_size as select * from v$type_size;
  311. drop public synonym v$type_size;
  312. create public synonym v$type_size for v_$type_size;
  313.  
  314. create or replace view v_$archive as select * from v$archive;
  315. drop public synonym v$archive;
  316. create public synonym v$archive for v_$archive;
  317.  
  318. create or replace view v_$circuit as select * from v$circuit;
  319. drop public synonym v$circuit;
  320. create public synonym v$circuit for v_$circuit;
  321.  
  322. create or replace view v_$database as select * from v$database;
  323. drop public synonym v$database;
  324. create public synonym v$database for v_$database;
  325.  
  326. create or replace view v_$dispatcher as select * from v$dispatcher;
  327. drop public synonym v$dispatcher;
  328. create public synonym v$dispatcher for v_$dispatcher;
  329.  
  330. create or replace view v_$loghist as select * from v$loghist;
  331. drop public synonym v$loghist;
  332. create public synonym v$loghist for v_$loghist;
  333.  
  334. REM create or replace view v_$plsarea as select * from v$plsarea;
  335. drop public synonym v$plsarea;
  336. REM create public synonym v$plsarea for v_$plsarea;
  337.  
  338. create or replace view v_$sqlarea as select * from v$sqlarea;
  339. drop public synonym v$sqlarea;
  340. create public synonym v$sqlarea for v_$sqlarea;
  341.  
  342. create or replace view v_$db_object_cache as select * from v$db_object_cache;
  343. drop public synonym v$db_object_cache;
  344. create public synonym v$db_object_cache for v_$db_object_cache;
  345.  
  346. create or replace view v_$open_cursor as select * from v$open_cursor;
  347. drop public synonym v$open_cursor;
  348. create public synonym v$open_cursor for v_$open_cursor;
  349.  
  350. create or replace view v_$option as select * from v$option;
  351. drop public synonym v$option;
  352. create public synonym v$option for v_$option;
  353. grant select on v_$option to public;
  354.  
  355. create or replace view v_$version as select * from v$version;
  356. drop public synonym v$version;
  357. create public synonym v$version for v_$version;
  358. grant select on v_$version to public;
  359.  
  360. create or replace view v_$pq_sesstat as select * from v$pq_sesstat;
  361. drop public synonym v$pq_sesstat;
  362. create public synonym v$pq_sesstat for v_$pq_sesstat;
  363. grant select on v_$pq_sesstat to public;
  364.  
  365. create or replace view v_$pq_sysstat as select * from v$pq_sysstat;
  366. drop public synonym v$pq_sysstat;
  367. create public synonym v$pq_sysstat for v_$pq_sysstat;
  368.  
  369. create or replace view v_$pq_slave as select * from v$pq_slave;
  370. drop public synonym v$pq_slave;
  371. create public synonym v$pq_slave for v_$pq_slave;
  372.  
  373. create or replace view v_$queue as select * from v$queue;
  374. drop public synonym v$queue;
  375. create public synonym v$queue for v_$queue;
  376.  
  377. create or replace view v_$mts as select * from v$mts;
  378. drop public synonym v$mts;
  379. create public synonym v$mts for v_$mts;
  380.  
  381. create or replace view v_$dblink as select * from v$dblink;
  382. drop public synonym v$dblink;
  383. create public synonym v$dblink for v_$dblink;
  384.  
  385. create or replace view v_$reqdist as select * from v$reqdist;
  386. drop public synonym v$reqdist;
  387. create public synonym v$reqdist for v_$reqdist;
  388.  
  389. create or replace view v_$sgastat as select * from v$sgastat;
  390. drop public synonym v$sgastat;
  391. create public synonym v$sgastat for v_$sgastat;
  392.  
  393. create or replace view v_$waitstat as select * from v$waitstat;
  394. drop public synonym v$waitstat;
  395. create public synonym v$waitstat for v_$waitstat;
  396.  
  397. create or replace view v_$shared_server as select * from v$shared_server;
  398. drop public synonym v$shared_server;
  399. create public synonym v$shared_server for v_$shared_server;
  400.  
  401. create or replace view v_$timer as select * from v$timer;
  402. drop public synonym v$timer;
  403. create public synonym v$timer for v_$timer;
  404.  
  405. create or replace view v_$recover_file as select * from v$recover_file;
  406. drop public synonym v$recover_file;
  407. create public synonym v$recover_file for v_$recover_file;
  408.  
  409. create or replace view v_$backup as select * from v$backup;
  410. drop public synonym v$backup;
  411. create public synonym v$backup for v_$backup;
  412.  
  413. create or replace view v_$log_history as select * from v$log_history;
  414. drop public synonym v$log_history;
  415. create public synonym v$log_history for v_$log_history;
  416.  
  417. create or replace view v_$recovery_log as select * from v$recovery_log;
  418. drop public synonym v$recovery_log;
  419. create public synonym v$recovery_log for v_$recovery_log;
  420.  
  421. create or replace view v_$fixed_table as select * from v$fixed_table;
  422. drop public synonym v$fixed_table;
  423. create public synonym v$fixed_table for v_$fixed_table;
  424.  
  425. create or replace view v_$session_cursor_cache as 
  426.   select * from v$session_cursor_cache;
  427. drop public synonym v$session_cursor_cache;
  428. create public synonym v$session_cursor_cache for v_$session_cursor_cache;
  429.  
  430. create or replace view v_$session_wait as 
  431.   select * from v$session_wait;
  432. drop public synonym v$session_wait;
  433. create public synonym v$session_wait for v_$session_wait;
  434.  
  435. create or replace view v_$session_event as 
  436.   select * from v$session_event;
  437. drop public synonym v$session_event;
  438. create public synonym v$session_event for v_$session_event;
  439.  
  440. create or replace view v_$system_event as 
  441.   select * from v$system_event;
  442. drop public synonym v$system_event;
  443. create public synonym v$system_event for v_$system_event;
  444.  
  445. create or replace view v_$system_cursor_cache as 
  446.   select * from v$system_cursor_cache;
  447. drop public synonym v$system_cursor_cache;
  448. create public synonym v$system_cursor_cache for v_$system_cursor_cache;
  449.  
  450. create or replace view v_$sess_io as
  451.   select * from v$sess_io;
  452. drop public synonym v$sess_io;
  453. create public synonym v$sess_io for v_$sess_io;
  454.  
  455. create or replace view v_$compatibility as
  456.   select * from v$compatibility;
  457. drop public synonym v$compatibility;
  458. create public synonym v$compatibility for v_$compatibility;
  459.  
  460. create or replace view v_$compatseg as
  461.   select * from v$compatseg;
  462. drop public synonym v$compatseg;
  463. create public synonym v$compatseg for v_$compatseg;
  464.  
  465. remark
  466. remark  FAMILY "PRIVILEGE MAP"
  467. remark  Tables for mapping privilege numbers to privilege names.
  468. remark
  469. remark  SYSTEM_PRIVILEGE_MAP now in sql.bsq
  470. remark
  471. remark  TABLE_PRIVILEGE_MAP now in sql.bsq
  472. remark
  473. remark
  474. remark  FAMILY "PRIVS"
  475. remark
  476.  
  477. create or replace view SESSION_PRIVS
  478.     (PRIVILEGE)
  479. as
  480. select spm.name
  481. from sys.v$enabledprivs ep, system_privilege_map spm
  482. where spm.privilege = ep.priv_number
  483. /
  484. comment on table SESSION_PRIVS is
  485. 'Privileges which the user currently has set'
  486. /
  487. comment on column SESSION_PRIVS.PRIVILEGE is
  488. 'Privilege Name'
  489. /
  490. drop public synonym SESSION_PRIVS
  491. /
  492. create public synonym SESSION_PRIVS for SESSION_PRIVS
  493. /
  494. grant select on SESSION_PRIVS to PUBLIC with grant option
  495. /
  496.  
  497. remark
  498. remark  FAMILY "ROLES"
  499. remark
  500. create or replace view SESSION_ROLES
  501.     (ROLE)
  502. as
  503. select u.name
  504. from x$kzsro,user$ u
  505. where kzsrorol!=userenv('SCHEMAID') and kzsrorol!=1 and u.user#=kzsrorol
  506. /
  507. comment on table SESSION_ROLES is
  508. 'Roles which the user currently has enabled.'
  509. /
  510. comment on column SESSION_ROLES.ROLE is
  511. 'Role name'
  512. /
  513. drop public synonym SESSION_ROLES
  514. /
  515. create public synonym SESSION_ROLES for SESSION_ROLES
  516. /
  517. grant select on SESSION_ROLES to PUBLIC with grant option
  518. /
  519. create or replace view ROLE_SYS_PRIVS
  520.     (ROLE, PRIVILEGE, ADMIN_OPTION)
  521. as
  522. select u.name,spm.name,decode(min(option$),1,'YES','NO')
  523. from  sys.user$ u, sys.system_privilege_map spm, sys.sysauth$ sa
  524. where grantee# in 
  525.    (select distinct(privilege#)
  526.     from sys.sysauth$ sa
  527.     where privilege# > 0 
  528.     connect by prior sa.privilege# = sa.grantee#
  529.     start with grantee#=userenv('SCHEMAID') or grantee#=1 or grantee# in
  530.       (select kzdosrol from x$kzdos))
  531.   and u.user#=sa.grantee# and sa.privilege#=spm.privilege
  532. group by u.name, spm.name
  533. /
  534. comment on table ROLE_SYS_PRIVS is
  535. 'System privileges granted to roles'
  536. /
  537. comment on column ROLE_SYS_PRIVS.ROLE is
  538. 'Role name'
  539. /
  540. comment on column ROLE_SYS_PRIVS.PRIVILEGE is
  541. 'System Privilege'
  542. /
  543. comment on column ROLE_SYS_PRIVS.ADMIN_OPTION is
  544. 'Grant was with the ADMIN option'
  545. /
  546. drop public synonym ROLE_SYS_PRIVS
  547. /
  548. create public synonym ROLE_SYS_PRIVS for ROLE_SYS_PRIVS
  549. /
  550. grant select on ROLE_SYS_PRIVS to PUBLIC with grant option
  551. /
  552. create or replace view ROLE_TAB_PRIVS
  553.     (ROLE, OWNER, TABLE_NAME, COLUMN_NAME, PRIVILEGE, GRANTABLE)
  554. as
  555. select u1.name,u2.name,o.name,col$.name,tpm.name, 
  556.        decode(max(oa.option$), 1, 'YES', 'NO')
  557. from  sys.user$ u1,sys.user$ u2,sys.table_privilege_map tpm,
  558.       sys.objauth$ oa,sys.obj$ o,sys.col$
  559. where grantee# in        
  560.    (select distinct(privilege#)
  561.     from sys.sysauth$ sa
  562.     where privilege# > 0 
  563.     connect by prior sa.privilege# = sa.grantee#
  564.     start with grantee#=userenv('SCHEMAID') or grantee#=1 or grantee# in
  565.       (select kzdosrol from x$kzdos))
  566.    and u1.user#=oa.grantee# and oa.privilege#=tpm.privilege
  567.    and oa.obj#=o.obj# and oa.obj#=col$.obj#(+) and oa.col#=col$.col#(+)
  568.    and u2.user#=o.owner#
  569. group by u1.name,u2.name,o.name,col$.name,tpm.name
  570. /
  571. comment on table ROLE_TAB_PRIVS is
  572. 'Table privileges granted to roles'
  573. /
  574. comment on column ROLE_TAB_PRIVS.ROLE is
  575. 'Role Name'
  576. /
  577. comment on column ROLE_TAB_PRIVS.TABLE_NAME is
  578. 'Table Name or Sequence Name'
  579. /
  580. comment on column ROLE_TAB_PRIVS.COLUMN_NAME is
  581. 'Column Name if applicable'
  582. /
  583. comment on column ROLE_TAB_PRIVS.PRIVILEGE is
  584. 'Table Privilege'
  585. /
  586. drop public synonym ROLE_TAB_PRIVS
  587. /
  588. create public synonym ROLE_TAB_PRIVS for ROLE_TAB_PRIVS
  589. /
  590. grant select on ROLE_TAB_PRIVS to PUBLIC with grant option
  591. /
  592. create or replace view ROLE_ROLE_PRIVS
  593.     (ROLE, GRANTED_ROLE, ADMIN_OPTION)
  594. as
  595. select u1.name,u2.name,decode(min(option$),1,'YES','NO')
  596. from  sys.user$ u1, sys.user$ u2, sys.sysauth$ sa
  597. where grantee# in 
  598.    (select distinct(privilege#)
  599.     from sys.sysauth$ sa
  600.     where privilege# > 0 
  601.     connect by prior sa.privilege# = sa.grantee#
  602.     start with grantee#=userenv('SCHEMAID') or grantee#=1 or grantee# in
  603.       (select kzdosrol from x$kzdos))
  604.    and u1.user#=sa.grantee# and u2.user#=sa.privilege#
  605. group by u1.name,u2.name
  606. /
  607. comment on table ROLE_ROLE_PRIVS is
  608. 'Roles which are granted to roles'
  609. /
  610. comment on column ROLE_ROLE_PRIVS.ROLE is
  611. 'Role Name'
  612. /
  613. comment on column ROLE_ROLE_PRIVS.GRANTED_ROLE is
  614. 'Role which was granted'
  615. /
  616. comment on column ROLE_ROLE_PRIVS.ADMIN_OPTION is
  617. 'Grant was with the ADMIN option'
  618. /
  619. drop public synonym ROLE_ROLE_PRIVS
  620. /
  621. create public synonym ROLE_ROLE_PRIVS for ROLE_ROLE_PRIVS
  622. /
  623. grant select on ROLE_ROLE_PRIVS to PUBLIC with grant option
  624. /
  625. create or replace view DBA_ROLES (ROLE, PASSWORD_REQUIRED)
  626. as
  627. select name, decode(password, null, 'NO', 'EXTERNAL', 'EXTERNAL', 'YES')
  628. from  user$
  629. where type = 0 and name not in ('PUBLIC', '_NEXT_USER')
  630. /
  631. comment on table DBA_ROLES is
  632. 'All Roles which exist in the database'
  633. /
  634. comment on column DBA_ROLES.ROLE is
  635. 'Role Name'
  636. /
  637. comment on column DBA_ROLES.PASSWORD_REQUIRED is
  638. 'Indicates if the role requires a password to be enabled'
  639. /
  640. remark
  641. remark These are table that actually enables the user to see his or her 
  642. remark limits
  643. remark
  644. create or replace view DBA_PROFILES
  645.     (PROFILE, RESOURCE_NAME, LIMIT)
  646. as select n.name, m.name,
  647.       decode (u.limit, 0, 'DEFAULT', 2147483647, 'UNLIMITED', 
  648.                u.limit)
  649.   from sys.profile$ u, sys.profname$ n, sys.resource_map m
  650.   where u.resource# = m.resource#
  651.   and u.type=0
  652.   and n.profile# = u.profile#
  653. /
  654. comment on table DBA_PROFILES is
  655. 'Display all profiles and their limits'
  656. /
  657. comment on column DBA_PROFILES.PROFILE is
  658. 'Profile name'
  659. /
  660. comment on column DBA_PROFILES.RESOURCE_NAME is
  661. 'Resource name'
  662. /
  663. comment on column DBA_PROFILES.LIMIT is
  664. 'Limit placed on this resource for this profile'
  665. /
  666.  
  667. REM
  668. REM  This view enables the user to see his own profile limits
  669. REM
  670. create or replace view USER_RESOURCE_LIMITS
  671.     (RESOURCE_NAME, LIMIT)
  672. as select m.name,
  673.       decode (u.limit, 2147483647, 'UNLIMITED', 
  674.                0, decode (p.limit, 2147483647, 'UNLIMITED',
  675.                            p.limit),
  676.                u.limit)
  677.   from sys.profile$ u, sys.profile$ p,
  678.        sys.resource_map m, user$ s
  679.   where u.resource# = m.resource#
  680.   and p.profile# = 0 
  681.   and p.resource# = u.resource#
  682.   and u.type =0
  683.   and s.resource$ = u.profile#
  684.   and s.user# = userenv('SCHEMAID')
  685. /
  686. comment on table USER_RESOURCE_LIMITS is
  687. 'Display resource limit of the user'
  688. /
  689. comment on column USER_RESOURCE_LIMITS.RESOURCE_NAME is
  690. 'Resource name'
  691. /
  692. comment on column USER_RESOURCE_LIMITS.LIMIT is
  693. 'Limit placed on this resource'
  694. /
  695. drop public synonym USER_RESOURCE_LIMITS
  696. /
  697. create public synonym USER_RESOURCE_LIMITS for USER_RESOURCE_LIMITS
  698. /
  699. grant select on USER_RESOURCE_LIMITS to PUBLIC with grant option
  700. /
  701.  
  702. REM
  703. REM  This view shows the resource cost of the system
  704. REM
  705. create or replace view RESOURCE_COST
  706.     (RESOURCE_NAME, UNIT_COST)
  707. as select m.name,c.cost
  708.   from sys.resource_cost$ c, sys.resource_map m where 
  709.   c.resource# = m.resource#
  710.   and c.resource# in (2, 4, 7, 8)
  711. /
  712. comment on table RESOURCE_COST is
  713. 'Cost for each resource'
  714. /
  715. comment on column RESOURCE_COST.RESOURCE_NAME is
  716. 'Name of resource'
  717. /
  718. comment on column RESOURCE_COST.UNIT_COST is
  719. 'Cost for resource'
  720. /
  721. drop public synonym RESOURCE_COST
  722. /
  723. create public synonym RESOURCE_COST for RESOURCE_COST
  724. /
  725. grant select on RESOURCE_COST to PUBLIC
  726. /
  727.  
  728. remark
  729. remark  FAMILY "CATALOG"
  730. remark  Objects which may be used as tables in SQL statements: 
  731. remark  Tables, Views, Synonyms.
  732. remark               
  733.  
  734. create or replace view USER_CATALOG
  735.     (TABLE_NAME,
  736.      TABLE_TYPE)
  737. as
  738. select o.name,
  739.        decode(o.type, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
  740.                       4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE', 'UNDEFINED')
  741. from sys.obj$ o
  742. where o.owner# = userenv('SCHEMAID')
  743.   and o.type in (2, 4, 5, 6)
  744.   and o.linkname is null
  745. /
  746. comment on table USER_CATALOG is
  747. 'Tables, Views, Synonyms and Sequences owned by the user'
  748. /
  749. comment on column USER_CATALOG.TABLE_NAME is
  750. 'Name of the object'
  751. /
  752. comment on column USER_CATALOG.TABLE_TYPE is
  753. 'Type of the object'
  754. /
  755. drop public synonym USER_CATALOG
  756. /
  757. create public synonym USER_CATALOG for USER_CATALOG
  758. /
  759. drop public synonym CAT
  760. /
  761. create public synonym CAT for USER_CATALOG
  762. /
  763. grant select on USER_CATALOG to PUBLIC with grant option
  764. /
  765. remark
  766. remark  This view shows all tables, views, synonyms, and sequences owned by the
  767. remark  user and those tables, views, synonyms, and sequences that PUBLIC
  768. remark  has been granted access.
  769. remark
  770. create or replace view ALL_CATALOG
  771.     (OWNER, TABLE_NAME,
  772.      TABLE_TYPE)
  773. as
  774. select u.name, o.name,
  775.        decode(o.type, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
  776.                       4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE', 'UNDEFINED')
  777. from sys.user$ u, sys.obj$ o
  778. where o.owner# = u.user#
  779.   and o.type in (2, 4, 5, 6)
  780.   and o.linkname is null
  781.   and (o.owner# in (userenv('SCHEMAID'), 1)   /* public objects */
  782.        or
  783.        obj# in ( select obj#  /* directly granted privileges */
  784.                  from sys.objauth$
  785.                  where grantee# in ( select kzsrorol
  786.                                       from x$kzsro
  787.                                     )
  788.                 )
  789.        or
  790.        (
  791.       o.type in (7, 8, 9) /* prc, fcn, pkg */
  792.       and
  793.       exists (select null from v$enabledprivs
  794.           where priv_number = -144 /* EXECUTE ANY PROCEDURE */)
  795.         )
  796.        or
  797.        (
  798.       o.type in (2, 4, 5) /* table, view, synonym */
  799.       and
  800.       exists (select null from v$enabledprivs
  801.           where priv_number in (-45 /* LOCK ANY TABLE */,
  802.                     -47 /* SELECT ANY TABLE */,
  803.                     -48 /* INSERT ANY TABLE */,
  804.                     -49 /* UPDATE ANY TABLE */,
  805.                     -50 /* DELETE ANY TABLE */))
  806.        )
  807.        or
  808.        ( o.type = 6 /* sequence */
  809.      and
  810.      exists (select null from v$enabledprivs
  811.          where priv_number = -109 /* SELECT ANY SEQUENCE */)))
  812. /
  813. comment on table ALL_CATALOG is
  814. 'All tables, views, synonyms, sequences accessible to the user'
  815. /
  816. comment on column ALL_CATALOG.OWNER is
  817. 'Owner of the object'
  818. /
  819. comment on column ALL_CATALOG.TABLE_NAME is
  820. 'Name of the object'
  821. /
  822. comment on column ALL_CATALOG.TABLE_TYPE is
  823. 'Type of the object'
  824. /
  825. drop public synonym ALL_CATALOG
  826. /
  827. create public synonym ALL_CATALOG for ALL_CATALOG
  828. /
  829. grant select on ALL_CATALOG to PUBLIC with grant option
  830. /
  831. create or replace view DBA_CATALOG
  832.     (OWNER, TABLE_NAME,
  833.      TABLE_TYPE)
  834. as
  835. select u.name, o.name,
  836.        decode(o.type, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
  837.                       4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE', 'UNDEFINED')
  838. from sys.user$ u, sys.obj$ o
  839. where o.owner# = u.user#
  840.   and o.linkname is null
  841.   and o.type in (2, 4, 5, 6)
  842. /
  843. comment on table DBA_CATALOG is
  844. 'All database Tables, Views, Synonyms, Sequences'
  845. /
  846. comment on column DBA_CATALOG.OWNER is
  847. 'Owner of the object'
  848. /
  849. comment on column DBA_CATALOG.TABLE_NAME is
  850. 'Name of the object'
  851. /
  852. comment on column DBA_CATALOG.TABLE_TYPE is
  853. 'Type of the object'
  854. /
  855. remark
  856. remark  FAMILY "CLUSTERS"
  857. remark  CREATE CLUSTER parameters.
  858. remark  This family has no "ALL" member.
  859. remark
  860. create or replace view USER_CLUSTERS
  861.     (CLUSTER_NAME, TABLESPACE_NAME,
  862.      PCT_FREE, PCT_USED, KEY_SIZE,
  863.      INI_TRANS, MAX_TRANS,
  864.      INITIAL_EXTENT, NEXT_EXTENT,
  865.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE,
  866.      AVG_BLOCKS_PER_KEY,
  867.      CLUSTER_TYPE, FUNCTION, HASHKEYS,
  868.      DEGREE, INSTANCES, CACHE)
  869. as select o.name, ts.name,
  870.           c.pctfree$, c.pctused$, c.size$,c.initrans,c.maxtrans,
  871.           s.iniexts * ts.blocksize, s.extsize * ts.blocksize,
  872.           s.minexts, s.maxexts, s.extpct,
  873.           c.spare4, decode(c.hashkeys, 0, 'INDEX', 'HASH'),
  874.           decode(c.hashkeys, 0, NULL,
  875.                  decode(c.func, 0, 'COLUMN', 1, 'DEFAULT', NULL)),
  876.           c.hashkeys,
  877.           lpad(decode(c.spare5, 0, '1', 1, 'DEFAULT', to_char(c.spare5)), 10),
  878.           lpad(decode(mod(c.spare6, 65536), 0, '1', 1, 'DEFAULT',
  879.           to_char(mod(c.spare6, 65536))), 10),
  880.           lpad(decode(floor(c.spare6 / 65536), 0, 'N', 1, 'Y', '?'), 5)
  881. from sys.ts$ ts, sys.seg$ s, sys.clu$ c, sys.obj$ o
  882. where o.owner# = userenv('SCHEMAID')
  883.   and o.obj# = c.obj#
  884.   and c.ts# = ts.ts# 
  885.   and c.ts# = s.ts#
  886.   and c.file# = s.file#
  887.   and c.block# = s.block#
  888. /
  889. comment on table USER_CLUSTERS is
  890. 'Descriptions of user''s own clusters'
  891. /
  892. comment on column USER_CLUSTERS.CLUSTER_NAME is
  893. 'Name of the cluster'
  894. /
  895. comment on column USER_CLUSTERS.TABLESPACE_NAME is
  896. 'Name of the tablespace containing the cluster'
  897. /
  898. comment on column USER_CLUSTERS.PCT_FREE is
  899. 'Minimum percentage of free space in a block'
  900. /
  901. comment on column USER_CLUSTERS.PCT_USED is
  902. 'Minimum percentage of used space in a block'
  903. /
  904. comment on column USER_CLUSTERS.KEY_SIZE is
  905. 'Estimated size of cluster key plus associated rows'
  906. /
  907. comment on column USER_CLUSTERS.INI_TRANS is
  908. 'Initial number of transactions'
  909. /
  910. comment on column USER_CLUSTERS.MAX_TRANS is
  911. 'Maximum number of transactions'
  912. /
  913. comment on column USER_CLUSTERS.INITIAL_EXTENT is
  914. 'Size of the initial extent in bytes'
  915. /
  916. comment on column USER_CLUSTERS.NEXT_EXTENT is
  917. 'Size of secondary extents in bytes'
  918. /
  919. comment on column USER_CLUSTERS.MIN_EXTENTS is
  920. 'Minimum number of extents allowed in the segment'
  921. /
  922. comment on column USER_CLUSTERS.MAX_EXTENTS is
  923. 'Maximum number of extents allowed in the segment'
  924. /
  925. comment on column USER_CLUSTERS.PCT_INCREASE is
  926. 'Percentage increase in extent size'
  927. /
  928. comment on column USER_CLUSTERS.AVG_BLOCKS_PER_KEY is
  929. 'Average number of blocks containing rows with a given cluster key'
  930. /
  931. comment on column USER_CLUSTERS.CLUSTER_TYPE is
  932. 'Type of cluster: b-tree index or hash'
  933. /
  934. comment on column USER_CLUSTERS.FUNCTION is
  935. 'If a hash cluster, the hash function'
  936. /
  937. comment on column USER_CLUSTERS.HASHKEYS is
  938. 'If a hash cluster, the number of hash keys (hash buckets)'
  939. /
  940. comment on column USER_CLUSTERS.DEGREE is
  941. 'The number of threads per instance for scanning the cluster'
  942. /
  943. comment on column USER_CLUSTERS.INSTANCES is
  944. 'The number of instances across which the cluster is to be scanned'
  945. /
  946. comment on column USER_CLUSTERS.CACHE is
  947. 'Whether the cluster is to be cached in the buffer cache'
  948. /
  949. drop public synonym USER_CLUSTERS
  950. /
  951. create public synonym USER_CLUSTERS for USER_CLUSTERS
  952. /
  953. drop public synonym CLU
  954. /
  955. create public synonym CLU for USER_CLUSTERS
  956. /
  957. grant select on USER_CLUSTERS to PUBLIC with grant option
  958. /
  959. create or replace view DBA_CLUSTERS
  960.     (OWNER, CLUSTER_NAME, TABLESPACE_NAME,
  961.      PCT_FREE, PCT_USED, KEY_SIZE,
  962.      INI_TRANS, MAX_TRANS,
  963.      INITIAL_EXTENT, NEXT_EXTENT,
  964.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE,
  965.      AVG_BLOCKS_PER_KEY,
  966.      CLUSTER_TYPE, FUNCTION, HASHKEYS,
  967.      DEGREE, INSTANCES, CACHE)
  968. as select u.name, o.name, ts.name,
  969.           c.pctfree$, c.pctused$, c.size$,c.initrans,c.maxtrans,
  970.           s.iniexts * ts.blocksize, s.extsize * ts.blocksize,
  971.           s.minexts, s.maxexts, s.extpct,
  972.           c.spare4, decode(c.hashkeys, 0, 'INDEX', 'HASH'),
  973.           decode(c.hashkeys, 0, NULL,
  974.                  decode(c.func, 0, 'COLUMN', 1, 'DEFAULT', NULL)),
  975.           c.hashkeys,
  976.           lpad(decode(c.spare5, 0, '1', 1, 'DEFAULT', to_char(c.spare5)), 10),
  977.           lpad(decode(mod(c.spare6, 65536), 0, '1', 1, 'DEFAULT',
  978.           to_char(mod(c.spare6, 65536))), 10),
  979.           lpad(decode(floor(c.spare6 / 65536), 0, 'N', 1, 'Y', '?'), 5)
  980. from sys.user$ u, sys.ts$ ts, sys.seg$ s, sys.clu$ c, sys.obj$ o
  981. where o.owner# = u.user#
  982.   and o.obj# = c.obj#
  983.   and c.ts# = ts.ts#
  984.   and c.ts# = s.ts#
  985.   and c.file# = s.file#
  986.   and c.block# = s.block#
  987. /
  988. comment on table DBA_CLUSTERS is
  989. 'Description of all clusters in the database'
  990. /
  991. comment on column DBA_CLUSTERS.OWNER is
  992. 'Owner of the cluster'
  993. /
  994. comment on column DBA_CLUSTERS.CLUSTER_NAME is
  995. 'Name of the cluster'
  996. /
  997. comment on column DBA_CLUSTERS.TABLESPACE_NAME is
  998. 'Name of the tablespace containing the cluster'
  999. /
  1000. comment on column DBA_CLUSTERS.PCT_FREE is
  1001. 'Minimum percentage of free space in a block'
  1002. /
  1003. comment on column DBA_CLUSTERS.PCT_USED is
  1004. 'Minimum percentage of used space in a block'
  1005. /
  1006. comment on column DBA_CLUSTERS.KEY_SIZE is
  1007. 'Estimated size of cluster key plus associated rows'
  1008. /
  1009. comment on column DBA_CLUSTERS.INI_TRANS is
  1010. 'Initial number of transactions'
  1011. /
  1012. comment on column DBA_CLUSTERS.MAX_TRANS is
  1013. 'Maximum number of transactions'
  1014. /
  1015. comment on column DBA_CLUSTERS.INITIAL_EXTENT is
  1016. 'Size of the initial extent in bytes'
  1017. /
  1018. comment on column DBA_CLUSTERS.NEXT_EXTENT is
  1019. 'Size of secondary extents in bytes'
  1020. /
  1021. comment on column DBA_CLUSTERS.MIN_EXTENTS is
  1022. 'Minimum number of extents allowed in the segment'
  1023. /
  1024. comment on column DBA_CLUSTERS.MAX_EXTENTS is
  1025. 'Maximum number of extents allowed in the segment'
  1026. /
  1027. comment on column DBA_CLUSTERS.PCT_INCREASE is
  1028. 'Percentage increase in extent size'
  1029. /
  1030. comment on column DBA_CLUSTERS.AVG_BLOCKS_PER_KEY is
  1031. 'Average number of blocks containing rows with a given cluster key'
  1032. /
  1033. comment on column DBA_CLUSTERS.CLUSTER_TYPE is
  1034. 'Type of cluster: b-tree index or hash'
  1035. /
  1036. comment on column DBA_CLUSTERS.FUNCTION is
  1037. 'If a hash cluster, the hash function'
  1038. /
  1039. comment on column DBA_CLUSTERS.HASHKEYS is
  1040. 'If a hash cluster, the number of hash keys (hash buckets)'
  1041. /
  1042. comment on column DBA_CLUSTERS.DEGREE is
  1043. 'The number of threads per instance for scanning the cluster'
  1044. /
  1045. comment on column DBA_CLUSTERS.INSTANCES is
  1046. 'The number of instances across which the cluster is to be scanned'
  1047. /
  1048. comment on column DBA_CLUSTERS.CACHE is
  1049. 'Whether the cluster is to be cached in the buffer cache'
  1050. /
  1051. remark
  1052. remark  FAMILY "CLU_COLUMNS"
  1053. remark  Mapping of cluster columns to table columns.
  1054. remark  This family has no ALL member.
  1055. remark
  1056. create or replace view USER_CLU_COLUMNS
  1057.     (CLUSTER_NAME, CLU_COLUMN_NAME, TABLE_NAME, TAB_COLUMN_NAME)
  1058. as
  1059. select oc.name, cc.name, ot.name, tc.name
  1060. from sys.obj$ oc, sys.col$ cc, sys.obj$ ot, sys.col$ tc, sys.tab$ t
  1061. where oc.obj#    = cc.obj#
  1062.   and t.clu#     = oc.obj#
  1063.   and t.obj#     = tc.obj#
  1064.   and tc.segcol# = cc.segcol#
  1065.   and t.obj#     = ot.obj#
  1066.   and oc.type    = 3
  1067.   and oc.owner#  = userenv('SCHEMAID')
  1068. /
  1069. comment on table USER_CLU_COLUMNS is
  1070. 'Mapping of table columns to cluster columns'
  1071. /
  1072. comment on column USER_CLU_COLUMNS.CLUSTER_NAME is
  1073. 'Cluster name'
  1074. /
  1075. comment on column USER_CLU_COLUMNS.CLU_COLUMN_NAME is
  1076. 'Key column in the cluster'
  1077. /
  1078. comment on column USER_CLU_COLUMNS.TABLE_NAME is
  1079. 'Clustered table name'
  1080. /
  1081. comment on column USER_CLU_COLUMNS.TAB_COLUMN_NAME is
  1082. 'Key column in the table'
  1083. /
  1084. drop public synonym USER_CLU_COLUMNS
  1085. /
  1086. create public synonym USER_CLU_COLUMNS for USER_CLU_COLUMNS
  1087. /
  1088. grant select on USER_CLU_COLUMNS to PUBLIC with grant option
  1089. /
  1090. create or replace view DBA_CLU_COLUMNS
  1091.     (OWNER, CLUSTER_NAME, CLU_COLUMN_NAME, TABLE_NAME, TAB_COLUMN_NAME)
  1092. as
  1093. select u.name, oc.name, cc.name, ot.name, tc.name
  1094. from sys.user$ u, sys.obj$ oc, sys.col$ cc, sys.obj$ ot, sys.col$ tc,
  1095.      sys.tab$ t
  1096. where oc.owner#  = u.user#
  1097.   and oc.obj#    = cc.obj#
  1098.   and t.clu#     = oc.obj#
  1099.   and t.obj#     = tc.obj#
  1100.   and tc.segcol# = cc.segcol#
  1101.   and t.obj#     = ot.obj#
  1102.   and oc.type    = 3
  1103. /
  1104. comment on table DBA_CLU_COLUMNS is
  1105. 'Mapping of table columns to cluster columns'
  1106. /
  1107. comment on column DBA_CLU_COLUMNS.OWNER is
  1108. 'Owner of the cluster'
  1109. /
  1110. comment on column DBA_CLU_COLUMNS.CLUSTER_NAME is
  1111. 'Cluster name'
  1112. /
  1113. comment on column DBA_CLU_COLUMNS.CLU_COLUMN_NAME is
  1114. 'Key column in the cluster'
  1115. /
  1116. comment on column DBA_CLU_COLUMNS.TABLE_NAME is
  1117. 'Clustered table name'
  1118. /
  1119. comment on column DBA_CLU_COLUMNS.TAB_COLUMN_NAME is
  1120. 'Key column in the table'
  1121. /
  1122. remark
  1123. remark  FAMILY "COL_COMMENTS"
  1124. remark  Comments on columns of tables and views.
  1125. remark
  1126. create or replace view USER_COL_COMMENTS
  1127.     (TABLE_NAME, COLUMN_NAME, COMMENTS)
  1128. as
  1129. select o.name, c.name, co.comment$
  1130. from sys.obj$ o, sys.col$ c, sys.com$ co
  1131. where o.owner# = userenv('SCHEMAID')
  1132.   and o.type in (2, 4)
  1133.   and o.obj# = c.obj#
  1134.   and c.obj# = co.obj#(+)
  1135.   and c.col# = co.col#(+)
  1136. /
  1137. comment on table USER_COL_COMMENTS is
  1138. 'Comments on columns of user''s tables and views'
  1139. /
  1140. comment on column USER_COL_COMMENTS.TABLE_NAME is
  1141. 'Object name'
  1142. /
  1143. comment on column USER_COL_COMMENTS.COLUMN_NAME is
  1144. 'Column name'
  1145. /
  1146. comment on column USER_COL_COMMENTS.COMMENTS is
  1147. 'Comment on the column'
  1148. /
  1149. drop public synonym USER_COL_COMMENTS
  1150. /
  1151. create public synonym USER_COL_COMMENTS for USER_COL_COMMENTS
  1152. /
  1153. grant select on USER_COL_COMMENTS to PUBLIC with grant option
  1154. /
  1155. create or replace view ALL_COL_COMMENTS
  1156.     (OWNER, TABLE_NAME, COLUMN_NAME, COMMENTS)
  1157. as
  1158. select u.name, o.name, c.name, co.comment$
  1159. from sys.obj$ o, sys.col$ c, sys.user$ u, sys.com$ co
  1160. where o.owner# = u.user#
  1161.   and o.type in (2, 4, 5)
  1162.   and o.obj# = c.obj#
  1163.   and c.obj# = co.obj#(+)
  1164.   and c.col# = co.col#(+)
  1165.   and (o.owner# = userenv('SCHEMAID')
  1166.        or o.obj# in
  1167.          (select obj#
  1168.           from sys.objauth$
  1169.           where grantee# in ( select kzsrorol
  1170.                               from x$kzsro
  1171.                             )
  1172.           )
  1173.        or
  1174.      exists (select null from v$enabledprivs
  1175.              where priv_number in (-45 /* LOCK ANY TABLE */,
  1176.                        -47 /* SELECT ANY TABLE */,
  1177.                        -48 /* INSERT ANY TABLE */,
  1178.                        -49 /* UPDATE ANY TABLE */,
  1179.                        -50 /* DELETE ANY TABLE */))
  1180.       )
  1181. /
  1182. comment on table ALL_COL_COMMENTS is
  1183. 'Comments on columns of accessible tables and views'
  1184. /
  1185. comment on column ALL_COL_COMMENTS.OWNER is
  1186. 'Owner of the object'
  1187. /
  1188. comment on column ALL_COL_COMMENTS.TABLE_NAME is
  1189. 'Name of the object'
  1190. /
  1191. comment on column ALL_COL_COMMENTS.COLUMN_NAME is
  1192. 'Name of the column'
  1193. /
  1194. comment on column ALL_COL_COMMENTS.COMMENTS is
  1195. 'Comment on the column'
  1196. /
  1197. drop public synonym ALL_COL_COMMENTS
  1198. /
  1199. create public synonym ALL_COL_COMMENTS for ALL_COL_COMMENTS
  1200. /
  1201. grant select on ALL_COL_COMMENTS to PUBLIC with grant option
  1202. /
  1203. create or replace view DBA_COL_COMMENTS
  1204.     (OWNER, TABLE_NAME, COLUMN_NAME, COMMENTS)
  1205. as
  1206. select u.name, o.name, c.name, co.comment$
  1207. from sys.obj$ o, sys.col$ c, sys.user$ u, sys.com$ co
  1208. where o.owner# = u.user#
  1209.   and o.type in (2, 4)
  1210.   and o.obj# = c.obj#
  1211.   and c.obj# = co.obj#(+)
  1212.   and c.col# = co.col#(+)
  1213. /
  1214. comment on table DBA_COL_COMMENTS is
  1215. 'Comments on columns of all tables and views'
  1216. /
  1217. comment on column DBA_COL_COMMENTS.OWNER is
  1218. 'Name of the owner of the object'
  1219. /
  1220. comment on column DBA_COL_COMMENTS.TABLE_NAME is
  1221. 'Name of the object'
  1222. /
  1223. comment on column DBA_COL_COMMENTS.COLUMN_NAME is
  1224. 'Name of the column'
  1225. /
  1226. comment on column DBA_COL_COMMENTS.COMMENTS is
  1227. 'Comment on the object'
  1228. /
  1229. remark
  1230. remark  FAMILY "COL_PRIVS"
  1231. remark  Grants on columns.
  1232. remark
  1233. create or replace view USER_COL_PRIVS
  1234.       (GRANTEE, OWNER, TABLE_NAME, COLUMN_NAME, GRANTOR, PRIVILEGE, GRANTABLE)
  1235. as
  1236. select ue.name, u.name, o.name, c.name, ur.name, tpm.name, 
  1237.        decode(oa.option$, 1, 'YES', 'NO')
  1238. from sys.objauth$ oa, sys.obj$ o, sys.user$ u, sys.user$ ur, sys.user$ ue,
  1239.      sys.col$ c, table_privilege_map tpm
  1240. where oa.obj# = o.obj#
  1241.   and oa.grantor# = ur.user#
  1242.   and oa.grantee# = ue.user#
  1243.   and u.user# = o.owner#
  1244.   and oa.obj# = c.obj#
  1245.   and oa.col# = c.col#
  1246.   and oa.col# is not null
  1247.   and oa.privilege# = tpm.privilege
  1248.   and userenv('SCHEMAID') in (oa.grantor#, oa.grantee#, o.owner#)
  1249. /
  1250. comment on table USER_COL_PRIVS is
  1251. 'Grants on columns for which the user is the owner, grantor or grantee'
  1252. /
  1253. comment on column USER_COL_PRIVS.GRANTEE is
  1254. 'Name of the user to whom access was granted'
  1255. /
  1256. comment on column USER_COL_PRIVS.OWNER is
  1257. 'Username of the owner of the object'
  1258. /
  1259. comment on column USER_COL_PRIVS.TABLE_NAME is
  1260. 'Name of the object'
  1261. /
  1262. comment on column USER_COL_PRIVS.COLUMN_NAME is
  1263. 'Name of the column'
  1264. /
  1265. comment on column USER_COL_PRIVS.GRANTOR is
  1266. 'Name of the user who performed the grant'
  1267. /
  1268. comment on column USER_COL_PRIVS.PRIVILEGE is
  1269. 'Column Privilege'
  1270. /
  1271. comment on column USER_COL_PRIVS.GRANTABLE is
  1272. 'Privilege is grantable'
  1273. /
  1274. drop public synonym USER_COL_PRIVS
  1275. /
  1276. create public synonym USER_COL_PRIVS for USER_COL_PRIVS
  1277. /
  1278. grant select on USER_COL_PRIVS to PUBLIC with grant option
  1279. /
  1280. create or replace view ALL_COL_PRIVS
  1281.       (GRANTOR, GRANTEE, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME,
  1282.        PRIVILEGE, GRANTABLE)
  1283. as
  1284. select ur.name, ue.name, u.name, o.name, c.name, tpm.name, 
  1285.        decode(oa.option$, 1, 'YES', 'NO')
  1286. from sys.objauth$ oa, sys.obj$ o, sys.user$ u, sys.user$ ur, sys.user$ ue,
  1287.      sys.col$ c, table_privilege_map tpm
  1288. where oa.obj# = o.obj#
  1289.   and oa.grantor# = ur.user#
  1290.   and oa.grantee# = ue.user#
  1291.   and u.user# = o.owner#
  1292.   and oa.obj# = c.obj#
  1293.   and oa.col# = c.col#
  1294.   and oa.col# is not null
  1295.   and oa.privilege# = tpm.privilege
  1296.   and (oa.grantor# = userenv('SCHEMAID') or
  1297.        oa.grantee# in (select kzsrorol from x$kzsro) or
  1298.        o.owner# = userenv('SCHEMAID'))
  1299. /
  1300. comment on table ALL_COL_PRIVS is
  1301. 'Grants on columns for which the user is the grantor, grantee, owner, 
  1302.  or an enabled role or PUBLIC is the grantee'
  1303. /
  1304. comment on column ALL_COL_PRIVS.GRANTOR is
  1305. 'Name of the user who performed the grant'
  1306. /
  1307. comment on column ALL_COL_PRIVS.GRANTEE is
  1308. 'Name of the user to whom access was granted'
  1309. /
  1310. comment on column ALL_COL_PRIVS.TABLE_SCHEMA is
  1311. 'Schema of the object'
  1312. /
  1313. comment on column ALL_COL_PRIVS.TABLE_NAME is
  1314. 'Name of the object'
  1315. /
  1316. comment on column ALL_COL_PRIVS.COLUMN_NAME is
  1317. 'Name of the column'
  1318. /
  1319. comment on column ALL_COL_PRIVS.PRIVILEGE is
  1320. 'Column Privilege'
  1321. /
  1322. comment on column ALL_COL_PRIVS.GRANTABLE is
  1323. 'Privilege is grantable'
  1324. /
  1325. drop public synonym ALL_COL_PRIVS
  1326. /
  1327. create public synonym ALL_COL_PRIVS for ALL_COL_PRIVS
  1328. /
  1329. grant select on ALL_COL_PRIVS to PUBLIC with grant option
  1330. /
  1331. create or replace view DBA_COL_PRIVS
  1332.       (GRANTEE, OWNER, TABLE_NAME, COLUMN_NAME, GRANTOR, PRIVILEGE, GRANTABLE)
  1333. as
  1334. select ue.name, u.name, o.name, c.name, ur.name, tpm.name, 
  1335.        decode(oa.option$, 1, 'YES', 'NO')
  1336. from sys.objauth$ oa, sys.obj$ o, sys.user$ u, sys.user$ ur, sys.user$ ue,
  1337.      sys.col$ c, table_privilege_map tpm
  1338. where oa.obj# = o.obj#
  1339.   and oa.grantor# = ur.user#
  1340.   and oa.grantee# = ue.user#
  1341.   and oa.obj# = c.obj#
  1342.   and oa.col# = c.col#
  1343.   and oa.col# is not null
  1344.   and oa.privilege# = tpm.privilege
  1345.   and u.user# = o.owner#
  1346. /
  1347. comment on table DBA_COL_PRIVS is
  1348. 'All grants on columns in the database'
  1349. /
  1350. comment on column DBA_COL_PRIVS.GRANTEE is
  1351. 'Name of the user to whom access was granted'
  1352. /
  1353. comment on column DBA_COL_PRIVS.OWNER is
  1354. 'Username of the owner of the object'
  1355. /
  1356. comment on column DBA_COL_PRIVS.TABLE_NAME is
  1357. 'Name of the object'
  1358. /
  1359. comment on column DBA_COL_PRIVS.COLUMN_NAME is
  1360. 'Name of the column'
  1361. /
  1362. comment on column DBA_COL_PRIVS.GRANTOR is
  1363. 'Name of the user who performed the grant'
  1364. /
  1365. comment on column DBA_COL_PRIVS.PRIVILEGE is
  1366. 'Column Privilege'
  1367. /
  1368. comment on column DBA_COL_PRIVS.GRANTABLE is
  1369. 'Privilege is grantable'
  1370. /
  1371. remark
  1372. remark  FAMILY "COL_PRIVS_MADE"
  1373. remark  Grants on columns made by the user.
  1374. remark  This family has no DBA member.
  1375. remark
  1376. create or replace view USER_COL_PRIVS_MADE
  1377.       (GRANTEE, TABLE_NAME, COLUMN_NAME, GRANTOR, PRIVILEGE, GRANTABLE)
  1378. as
  1379. select ue.name, o.name, c.name, ur.name, tpm.name, 
  1380.        decode(oa.option$, 1, 'YES', 'NO')
  1381. from sys.objauth$ oa, sys.obj$ o, sys.user$ ue, sys.user$ ur,
  1382.      sys.col$ c, table_privilege_map tpm
  1383. where oa.obj# = o.obj#
  1384.   and oa.grantor# = ur.user#
  1385.   and oa.grantee# = ue.user#
  1386.   and oa.obj# = c.obj#
  1387.   and oa.col# = c.col#
  1388.   and oa.col# is not null
  1389.   and oa.privilege# = tpm.privilege
  1390.   and o.owner# = userenv('SCHEMAID')
  1391. /
  1392. comment on table USER_COL_PRIVS_MADE is
  1393. 'All grants on columns of objects owned by the user'
  1394. /
  1395. comment on column USER_COL_PRIVS_MADE.GRANTEE is
  1396. 'Name of the user to whom access was granted'
  1397. /
  1398. comment on column USER_COL_PRIVS_MADE.TABLE_NAME is
  1399. 'Name of the object'
  1400. /
  1401. comment on column USER_COL_PRIVS_MADE.COLUMN_NAME is
  1402. 'Name of the column'
  1403. /
  1404. comment on column USER_COL_PRIVS_MADE.GRANTOR is
  1405. 'Name of the user who performed the grant'
  1406. /
  1407. comment on column USER_COL_PRIVS_MADE.PRIVILEGE is
  1408. 'Column Privilege'
  1409. /
  1410. comment on column USER_COL_PRIVS_MADE.GRANTABLE is
  1411. 'Privilege is grantable'
  1412. /
  1413. drop public synonym USER_COL_PRIVS_MADE
  1414. /
  1415. create public synonym USER_COL_PRIVS_MADE for USER_COL_PRIVS_MADE
  1416. /
  1417. grant select on USER_COL_PRIVS_MADE to PUBLIC with grant option
  1418. /
  1419. create or replace view ALL_COL_PRIVS_MADE
  1420.       (GRANTEE, OWNER, TABLE_NAME, COLUMN_NAME, GRANTOR, PRIVILEGE, GRANTABLE)
  1421. as
  1422. select ue.name, u.name, o.name, c.name, ur.name, tpm.name, 
  1423.        decode(oa.option$, 1, 'YES', 'NO')
  1424. from sys.objauth$ oa, sys.obj$ o, sys.user$ u, sys.user$ ur, sys.user$ ue,
  1425.      sys.col$ c, table_privilege_map tpm
  1426. where oa.obj# = o.obj#
  1427.   and oa.grantor# = ur.user#
  1428.   and oa.grantee# = ue.user#
  1429.   and u.user# = o.owner#
  1430.   and oa.obj# = c.obj#
  1431.   and oa.col# = c.col#
  1432.   and oa.col# is not null
  1433.   and oa.privilege# = tpm.privilege
  1434.   and userenv('SCHEMAID') in (o.owner#, oa.grantor#)
  1435. /
  1436. comment on table ALL_COL_PRIVS_MADE is
  1437. 'Grants on columns for which the user is owner or grantor'
  1438. /
  1439. comment on column ALL_COL_PRIVS_MADE.GRANTEE is
  1440. 'Name of the user to whom access was granted'
  1441. /
  1442. comment on column ALL_COL_PRIVS_MADE.OWNER is
  1443. 'Username of the owner of the object'
  1444. /
  1445. comment on column ALL_COL_PRIVS_MADE.TABLE_NAME is
  1446. 'Name of the object'
  1447. /
  1448. comment on column ALL_COL_PRIVS_MADE.COLUMN_NAME is
  1449. 'Name of the column'
  1450. /
  1451. comment on column ALL_COL_PRIVS_MADE.GRANTOR is
  1452. 'Name of the user who performed the grant'
  1453. /
  1454. comment on column ALL_COL_PRIVS_MADE.PRIVILEGE is
  1455. 'Column Privilege'
  1456. /
  1457. comment on column ALL_COL_PRIVS_MADE.GRANTABLE is
  1458. 'Privilege is grantable'
  1459. /
  1460. drop public synonym ALL_COL_PRIVS_MADE
  1461. /
  1462. create public synonym ALL_COL_PRIVS_MADE for ALL_COL_PRIVS_MADE
  1463. /
  1464. grant select on ALL_COL_PRIVS_MADE to PUBLIC with grant option
  1465. /
  1466. remark
  1467. remark  FAMILY "COL_PRIVS_RECD"
  1468. remark  Received grants on columns
  1469. remark
  1470. create or replace view USER_COL_PRIVS_RECD
  1471.       (OWNER, TABLE_NAME, COLUMN_NAME, GRANTOR, PRIVILEGE, GRANTABLE)
  1472. as
  1473. select u.name, o.name, c.name, ur.name, tpm.name, 
  1474.        decode(oa.option$, 1, 'YES', 'NO')
  1475. from sys.objauth$ oa, sys.obj$ o, sys.user$ u, sys.user$ ur,
  1476.      sys.col$ c, table_privilege_map tpm
  1477. where oa.obj# = o.obj#
  1478.   and oa.grantor# = ur.user#
  1479.   and u.user# = o.owner#
  1480.   and oa.obj# = c.obj#
  1481.   and oa.col# = c.col#
  1482.   and oa.col# is not null
  1483.   and oa.privilege# = tpm.privilege
  1484.   and oa.grantee# = userenv('SCHEMAID')
  1485. /
  1486. comment on table USER_COL_PRIVS_RECD is
  1487. 'Grants on columns for which the user is the grantee'
  1488. /
  1489. comment on column USER_COL_PRIVS_RECD.OWNER is
  1490. 'Username of the owner of the object'
  1491. /
  1492. comment on column USER_COL_PRIVS_RECD.TABLE_NAME is
  1493. 'Name of the object'
  1494. /
  1495. comment on column USER_COL_PRIVS_RECD.COLUMN_NAME is
  1496. 'Name of the column'
  1497. /
  1498. comment on column USER_COL_PRIVS_RECD.GRANTOR is
  1499. 'Name of the user who performed the grant'
  1500. /
  1501. comment on column USER_COL_PRIVS_RECD.PRIVILEGE is
  1502. 'Column Privilege'
  1503. /
  1504. comment on column USER_COL_PRIVS_RECD.GRANTABLE is
  1505. 'Privilege is grantable'
  1506. /
  1507. drop public synonym USER_COL_PRIVS_RECD
  1508. /
  1509. create public synonym USER_COL_PRIVS_RECD for USER_COL_PRIVS_RECD
  1510. /
  1511. grant select on USER_COL_PRIVS_RECD to PUBLIC with grant option
  1512. /
  1513. create or replace view ALL_COL_PRIVS_RECD
  1514.       (GRANTEE, OWNER, TABLE_NAME, COLUMN_NAME, GRANTOR, PRIVILEGE, GRANTABLE)
  1515. as
  1516. select ue.name, u.name, o.name, c.name, ur.name, tpm.name, 
  1517.        decode(oa.option$, 1, 'YES', 'NO')
  1518. from sys.objauth$ oa, sys.obj$ o, sys.user$ u, sys.user$ ur, sys.user$ ue,
  1519.      sys.col$ c, table_privilege_map tpm
  1520. where oa.obj# = o.obj#
  1521.   and oa.grantor# = ur.user#
  1522.   and oa.grantee# = ue.user#
  1523.   and u.user# = o.owner#
  1524.   and oa.obj# = c.obj#
  1525.   and oa.col# = c.col#
  1526.   and oa.col# is not null
  1527.   and oa.privilege# = tpm.privilege
  1528.   and oa.grantee# in (select kzsrorol from x$kzsro)
  1529. /
  1530. comment on table ALL_COL_PRIVS_RECD is
  1531. 'Grants on columns for which the user, PUBLIC or enabled role is the grantee'
  1532. /
  1533. comment on column ALL_COL_PRIVS_RECD.GRANTEE is
  1534. 'Name of the user to whom access was granted'
  1535. /
  1536. comment on column ALL_COL_PRIVS_RECD.OWNER is
  1537. 'Username of the owner of the object'
  1538. /
  1539. comment on column ALL_COL_PRIVS_RECD.TABLE_NAME is
  1540. 'Name of the object'
  1541. /
  1542. comment on column ALL_COL_PRIVS_RECD.COLUMN_NAME is
  1543. 'Name of the column'
  1544. /
  1545. comment on column ALL_COL_PRIVS_RECD.GRANTOR is
  1546. 'Name of the user who performed the grant'
  1547. /
  1548. comment on column ALL_COL_PRIVS_RECD.PRIVILEGE is
  1549. 'Column privilege'
  1550. /
  1551. comment on column ALL_COL_PRIVS_RECD.GRANTABLE is
  1552. 'Privilege is grantable'
  1553. /
  1554. drop public synonym ALL_COL_PRIVS_RECD
  1555. /
  1556. create public synonym ALL_COL_PRIVS_RECD for ALL_COL_PRIVS_RECD
  1557. /
  1558. grant select on ALL_COL_PRIVS_RECD to PUBLIC with grant option
  1559. /
  1560.  
  1561. remark
  1562. remark  FAMILY "DATA_FILES"
  1563. remark  Information about database files.
  1564. remark  This family has a DBA member only.
  1565. remark
  1566. create or replace view DBA_DATA_FILES
  1567.     (FILE_NAME, FILE_ID, TABLESPACE_NAME, 
  1568.      BYTES, BLOCKS, 
  1569.      STATUS)
  1570. as
  1571. select v.name, f.file#, ts.name, 
  1572.        ts.blocksize * f.blocks, f.blocks, 
  1573.        decode(f.status$, 1, 'INVALID', 2, 'AVAILABLE', 'UNDEFINED')
  1574. from sys.file$ f, sys.ts$ ts, sys.v$dbfile v
  1575. where v.file# = f.file# (+)
  1576.   and f.ts# = ts.ts# (+)
  1577. /
  1578. comment on table DBA_DATA_FILES is
  1579. 'Information about database files'
  1580. /
  1581. comment on column DBA_DATA_FILES.FILE_NAME is
  1582. 'Name of the database file'
  1583. /
  1584. comment on column DBA_DATA_FILES.FILE_ID is
  1585. 'ID of the database file'
  1586. /
  1587. comment on column DBA_DATA_FILES.TABLESPACE_NAME is
  1588. 'Name of the tablespace to which the file belongs'
  1589. /
  1590. comment on column DBA_DATA_FILES.BYTES is
  1591. 'Size of the file in bytes'
  1592. /
  1593. comment on column DBA_DATA_FILES.BLOCKS is
  1594. 'Size of the file in ORACLE blocks'
  1595. /
  1596. comment on column DBA_DATA_FILES.STATUS is
  1597. 'File status:  "INVALID" or "AVAILABLE"'
  1598. /
  1599. remark
  1600. remark  FAMILY "DB_LINKS"
  1601. remark  All relevant information about database links.
  1602. remark
  1603. create or replace view USER_DB_LINKS
  1604.     (DB_LINK, USERNAME, PASSWORD, HOST, CREATED)
  1605. as
  1606. select l.name, l.userid, l.password, l.host, l.ctime
  1607. from sys.link$ l
  1608. where l.owner# = userenv('SCHEMAID')
  1609. /
  1610. comment on table USER_DB_LINKS is
  1611. 'Database links owned by the user'
  1612. /
  1613. comment on column USER_DB_LINKS.DB_LINK is
  1614. 'Name of the database link'
  1615. /
  1616. comment on column USER_DB_LINKS.USERNAME is
  1617. 'Name of user to log on as'
  1618. /
  1619. comment on column USER_DB_LINKS.PASSWORD is
  1620. 'Password for logon'
  1621. /
  1622. comment on column USER_DB_LINKS.HOST is
  1623. 'SQL*Net string for connect'
  1624. /
  1625. comment on column USER_DB_LINKS.CREATED is
  1626. 'Creation time of the database link'
  1627. /
  1628. drop public synonym USER_DB_LINKS
  1629. /
  1630. create public synonym USER_DB_LINKS for USER_DB_LINKS
  1631. /
  1632. grant select on USER_DB_LINKS to PUBLIC with grant option
  1633. /
  1634. create or replace view ALL_DB_LINKS
  1635.     (OWNER, DB_LINK, USERNAME, HOST, CREATED)
  1636. as
  1637. select u.name, l.name, l.userid, l.host, l.ctime
  1638. from sys.link$ l, sys.user$ u
  1639. where l.owner# in ( select kzsrorol from x$kzsro )
  1640.   and l.owner# = u.user#
  1641. /
  1642. comment on table ALL_DB_LINKS is
  1643. 'Database links accessible to the user'
  1644. /
  1645. comment on column ALL_DB_LINKS.DB_LINK is
  1646. 'Name of the database link'
  1647. /
  1648. comment on column ALL_DB_LINKS.USERNAME is
  1649. 'Name of user to log on as'
  1650. /
  1651. comment on column ALL_DB_LINKS.HOST is
  1652. 'SQL*Net string for connect'
  1653. /
  1654. comment on column ALL_DB_LINKS.CREATED is
  1655. 'Creation time of the database link'
  1656. /
  1657. drop public synonym ALL_DB_LINKS
  1658. /
  1659. create public synonym ALL_DB_LINKS for ALL_DB_LINKS
  1660. /
  1661. grant select on ALL_DB_LINKS to PUBLIC with grant option
  1662. /
  1663. create or replace view DBA_DB_LINKS
  1664.     (OWNER, DB_LINK, USERNAME, HOST, CREATED)
  1665. as
  1666. select u.name, l.name, l.userid, l.host, l.ctime
  1667. from sys.link$ l, sys.user$ u
  1668. where l.owner# = u.user#
  1669. /
  1670. comment on table DBA_DB_LINKS is
  1671. 'All database links in the database'
  1672. /
  1673. comment on column DBA_DB_LINKS.DB_LINK is
  1674. 'Name of the database link'
  1675. /
  1676. comment on column DBA_DB_LINKS.USERNAME is
  1677. 'Name of user to log on as'
  1678. /
  1679. comment on column DBA_DB_LINKS.HOST is
  1680. 'SQL*Net string for connect'
  1681. /
  1682. comment on column DBA_DB_LINKS.CREATED is
  1683. 'Creation time of the database link'
  1684. /
  1685. remark
  1686. remark  VIEW "DICTIONARY"
  1687. remark  Online documentation for data dictionary tables and views.
  1688. remark  This view exists outside of the family schema.
  1689. remark
  1690. /* Find the names of public synonyms for views owned by SYS that
  1691. have names different from the synonym name.  This allows the user
  1692. to see the short-hand synonyms we have created.
  1693. */
  1694. create or replace view DICTIONARY
  1695.     (TABLE_NAME, COMMENTS)
  1696. as
  1697. select o.name, c.comment$
  1698. from sys.obj$ o, sys.com$ c
  1699. where o.obj# = c.obj#(+)
  1700.   and c.col# is null
  1701.   and o.owner# = 0
  1702.   and o.type = 4
  1703.   and (o.name like 'USER%'
  1704.        or o.name like 'ALL%'
  1705.        or (o.name like 'DBA%'
  1706.            and exists
  1707.                    (select null
  1708.                     from sys.v$enabledprivs
  1709.                     where priv_number = -47 /* SELECT ANY TABLE */)
  1710.            )
  1711.       )
  1712. union all
  1713. select o.name, c.comment$
  1714. from sys.obj$ o, sys.com$ c
  1715. where o.obj# = c.obj#(+)
  1716.   and o.owner# = 0
  1717.   and o.name in ('AUDIT_ACTIONS', 'COLUMN_PRIVILEGES', 'DICTIONARY',
  1718.         'DICT_COLUMNS', 'DUAL', 'GLOBAL_NAME', 'INDEX_HISTOGRAM',
  1719.         'INDEX_STATS', 'RESOURCE_COST', 'ROLE_ROLE_PRIVS', 'ROLE_SYS_PRIVS',
  1720.         'ROLE_TAB_PRIVS', 'SESSION_PRIVS', 'SESSION_ROLES',
  1721.         'TABLE_PRIVILEGES')
  1722.   and c.col# is null
  1723. union all
  1724. select so.name, 'Synonym for ' || sy.name
  1725. from sys.obj$ ro, sys.syn$ sy, sys.obj$ so
  1726. where so.type = 5
  1727.   and ro.linkname is null
  1728.   and so.owner# = 1
  1729.   and so.obj# = sy.obj#
  1730.   and so.name <> sy.name
  1731.   and sy.owner = 'SYS'
  1732.   and sy.name = ro.name
  1733.   and ro.owner# = 0
  1734.   and ro.type = 4
  1735. /
  1736. comment on table DICTIONARY is
  1737. 'Description of data dictionary tables and views'
  1738. /
  1739. comment on column DICTIONARY.TABLE_NAME is
  1740. 'Name of the object'
  1741. /
  1742. comment on column DICTIONARY.COMMENTS is
  1743. 'Text comment on the object'
  1744. /
  1745. drop public synonym DICTIONARY
  1746. /
  1747. create public synonym DICTIONARY for DICTIONARY
  1748. /
  1749. drop public synonym DICT
  1750. /
  1751. create public synonym DICT for DICTIONARY
  1752. /
  1753. grant select on DICTIONARY to PUBLIC with grant option
  1754. /
  1755. remark
  1756. remark  VIEW "DICT_COLUMNS"
  1757. remark  Online documentation for columns in data dictionary tables and views.
  1758. remark  This view exists outside of the family schema.
  1759. remark
  1760. /* Find the column comments for public synonyms for views owned by SYS that
  1761. have names different from the synonym name.  This allows the user
  1762. to see the columns of the short-hand synonyms we have created.
  1763. */
  1764. create or replace view DICT_COLUMNS
  1765.     (TABLE_NAME, COLUMN_NAME, COMMENTS)
  1766. as
  1767. select o.name, c.name, co.comment$
  1768. from sys.com$ co, sys.col$ c, sys.obj$ o
  1769. where o.owner# = 0
  1770.   and o.type = 4
  1771.   and (o.name like 'USER%'
  1772.        or o.name like 'ALL%'
  1773.        or (o.name like 'DBA%'
  1774.            and exists
  1775.                    (select null
  1776.                     from sys.v$enabledprivs
  1777.                     where priv_number = -47 /* SELECT ANY TABLE */)
  1778.            )
  1779.       )
  1780.   and o.obj# = c.obj#
  1781.   and c.obj# = co.obj#(+)
  1782.   and c.col# = co.col#(+)
  1783. union all
  1784. select o.name, c.name, co.comment$
  1785. from sys.com$ co, sys.col$ c, sys.obj$ o
  1786. where o.owner# = 0
  1787.   and o.name in ('AUDIT_ACTIONS','DUAL','DICTIONARY', 'DICT_COLUMNS')
  1788.   and o.obj# = c.obj#
  1789.   and c.obj# = co.obj#(+)
  1790.   and c.col# = co.col#(+)
  1791. union all
  1792. select so.name, c.name, co.comment$
  1793. from sys.com$ co,sys.col$ c, sys.obj$ ro, sys.syn$ sy, sys.obj$ so
  1794. where so.type = 5
  1795.   and so.owner# = 1
  1796.   and so.obj# = sy.obj#
  1797.   and so.name <> sy.name
  1798.   and sy.owner = 'SYS'
  1799.   and sy.name = ro.name
  1800.   and ro.owner# = 0
  1801.   and ro.type = 4
  1802.   and ro.obj# = c.obj#
  1803.   and c.col# = co.col#(+)  
  1804.   and c.obj# = co.obj#(+)
  1805. /
  1806. comment on table DICT_COLUMNS is
  1807. 'Description of columns in data dictionary tables and views'
  1808. /
  1809. comment on column DICT_COLUMNS.TABLE_NAME is
  1810. 'Name of the object that contains the column'
  1811. /
  1812. comment on column DICT_COLUMNS.COLUMN_NAME is
  1813. 'Name of the column'
  1814. /
  1815. comment on column DICT_COLUMNS.COMMENTS is
  1816. 'Text comment on the object'
  1817. /
  1818. drop public synonym DICT_COLUMNS
  1819. /
  1820. create public synonym DICT_COLUMNS for DICT_COLUMNS
  1821. /
  1822. grant select on DICT_COLUMNS to PUBLIC with grant option
  1823. /
  1824. remark
  1825. remark  FAMILY "EXP_OBJECTS"
  1826. remark  Objects that have been incrementally exported.
  1827. remark  This family has a DBA member only.
  1828. remark
  1829. create or replace view DBA_EXP_OBJECTS
  1830.     (OWNER, OBJECT_NAME, OBJECT_TYPE, CUMULATIVE, INCREMENTAL, EXPORT_VERSION)
  1831. as
  1832. select u.name, o.name, 
  1833.        decode(o.type, 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
  1834.                       4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE', 7, 'PROCEDURE',
  1835.                       8, 'FUNCTION', 9, 'PACKAGE', 11, 'PACKAGE BODY', 
  1836.               12, 'TRIGGER', 'UNDEFINED'),
  1837.        o.ctime, o.itime, o.expid
  1838. from sys.incexp o, sys.user$ u
  1839. where o.owner# = u.user#
  1840. /
  1841. comment on table DBA_EXP_OBJECTS is
  1842. 'Objects that have been incrementally exported'
  1843. /
  1844. comment on column DBA_EXP_OBJECTS.OWNER is
  1845. 'Owner of exported object'
  1846. comment on column DBA_EXP_OBJECTS.OBJECT_NAME is
  1847. 'Name of exported object'
  1848. comment on column DBA_EXP_OBJECTS.OBJECT_TYPE is
  1849. 'Type of exported object'
  1850. comment on column DBA_EXP_OBJECTS.CUMULATIVE is
  1851. 'Timestamp of last cumulative export'
  1852. comment on column DBA_EXP_OBJECTS.INCREMENTAL is
  1853. 'Timestamp of last incremental export'
  1854. comment on column DBA_EXP_OBJECTS.EXPORT_VERSION is
  1855. 'The id of the export session'
  1856. remark
  1857. remark  FAMILY "EXP_VERSION"
  1858. remark  Version number of last incremental export
  1859. remark  This family has a DBA member only.
  1860. remark
  1861. create or replace view DBA_EXP_VERSION 
  1862.     (EXP_VERSION)
  1863. as
  1864. select o.expid 
  1865. from sys.incvid o
  1866. /
  1867. comment on table DBA_EXP_VERSION is
  1868. 'Version number of the last export session'
  1869. /
  1870. comment on column DBA_EXP_VERSION.EXP_VERSION is
  1871. 'Version number of the last export session'
  1872. /
  1873. remark
  1874. remark  FAMILY "EXP_FILES"
  1875. remark  Files created by incremental exports.
  1876. remark  This family has a DBA member only.
  1877. remark
  1878. create or replace view DBA_EXP_FILES 
  1879.      (EXP_VERSION, EXP_TYPE, FILE_NAME, USER_NAME, TIMESTAMP)
  1880. as
  1881. select o.expid, decode(o.exptype, 'X', 'COMPLETE', 'C', 'CUMULATIVE',
  1882.                                   'I', 'INCREMENTAL', 'UNDEFINED'),
  1883.        o.expfile, o.expuser, o.expdate
  1884. from sys.incfil o
  1885. /
  1886. comment on table DBA_EXP_FILES is
  1887. 'Description of export files'
  1888. /
  1889. comment on column DBA_EXP_FILES.EXP_VERSION is
  1890. 'Version number of the export session'
  1891. /
  1892. comment on column DBA_EXP_FILES.FILE_NAME is
  1893. 'Name of the export file'
  1894. /
  1895. comment on column DBA_EXP_FILES.USER_NAME is
  1896. 'Name of user who executed export'
  1897. /
  1898. comment on column DBA_EXP_FILES.TIMESTAMP is
  1899. 'Timestamp of the export session'
  1900. /
  1901. remark
  1902. remark  FAMILY "FREE_SPACE"
  1903. remark  Free extents.
  1904. remark  This family has no ALL member.
  1905. remark
  1906. create or replace view USER_FREE_SPACE
  1907.     (TABLESPACE_NAME, FILE_ID, BLOCK_ID,
  1908.      BYTES, BLOCKS)
  1909. as
  1910. select ts.name, f.file#, f.block#,
  1911.        f.length * ts.blocksize, f.length
  1912. from sys.fet$ f, sys.ts$ ts
  1913. where f.ts# = ts.ts#
  1914.   and (ts.ts# in
  1915.          (select tsq.ts#
  1916.           from sys.tsq$ tsq
  1917.           where tsq.user# = userenv('SCHEMAID') and tsq.maxblocks != 0)
  1918.        or exists
  1919.           (select null
  1920.            from sys.v$enabledprivs
  1921.            where priv_number = -15 /* UNLIMITED TABLESPACE */)
  1922.       )
  1923. /
  1924. comment on table USER_FREE_SPACE is
  1925. 'Free extents in tablespaces accessible to the user'
  1926. /
  1927. comment on column USER_FREE_SPACE.TABLESPACE_NAME is
  1928. 'Name of the tablespace containing the extent'
  1929. /
  1930. comment on column USER_FREE_SPACE.FILE_ID is
  1931. 'ID number of the file containing the extent'
  1932. /
  1933. comment on column USER_FREE_SPACE.BLOCK_ID is
  1934. 'Starting block number of the extent'
  1935. /
  1936. comment on column USER_FREE_SPACE.BYTES is
  1937. 'Size of the extent in bytes'
  1938. /
  1939. comment on column USER_FREE_SPACE.BLOCKS is
  1940. 'Size of the extent in ORACLE blocks'
  1941. /
  1942. drop public synonym USER_FREE_SPACE
  1943. /
  1944. create public synonym USER_FREE_SPACE for USER_FREE_SPACE
  1945. /
  1946. grant select on USER_FREE_SPACE to PUBLIC with grant option
  1947. /
  1948. create or replace view DBA_FREE_SPACE
  1949.     (TABLESPACE_NAME, FILE_ID, BLOCK_ID,
  1950.      BYTES, BLOCKS)
  1951. as
  1952. select ts.name, f.file#, f.block#,
  1953.        f.length * ts.blocksize, f.length
  1954. from sys.fet$ f, sys.ts$ ts
  1955. where f.ts# = ts.ts#
  1956. /
  1957. comment on table DBA_FREE_SPACE is
  1958. 'Free extents in all tablespaces'
  1959. /
  1960. comment on column DBA_FREE_SPACE.TABLESPACE_NAME is
  1961. 'Name of the tablespace containing the extent'
  1962. /
  1963. comment on column DBA_FREE_SPACE.FILE_ID is
  1964. 'ID number of the file containing the extent'
  1965. /
  1966. comment on column DBA_FREE_SPACE.BLOCK_ID is
  1967. 'Starting block number of the extent'
  1968. /
  1969. comment on column DBA_FREE_SPACE.BYTES is
  1970. 'Size of the extent in bytes'
  1971. /
  1972. comment on column DBA_FREE_SPACE.BLOCKS is
  1973. 'Size of the extent in ORACLE blocks'
  1974. /
  1975. remark
  1976. remark  FAMILY "INDEXES"
  1977. remark  CREATE INDEX parameters.
  1978. remark
  1979. create or replace view USER_INDEXES
  1980.     (INDEX_NAME, TABLE_OWNER, TABLE_NAME,
  1981.      TABLE_TYPE,
  1982.      UNIQUENESS,
  1983.      TABLESPACE_NAME, INI_TRANS, MAX_TRANS,
  1984.      INITIAL_EXTENT, NEXT_EXTENT,
  1985.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE, PCT_FREE,
  1986.      BLEVEL, LEAF_BLOCKS, DISTINCT_KEYS, AVG_LEAF_BLOCKS_PER_KEY,
  1987.      AVG_DATA_BLOCKS_PER_KEY, CLUSTERING_FACTOR, STATUS)
  1988. as
  1989. select o.name, iu.name, io.name,
  1990.        decode(io.type, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
  1991.                        4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE', 'UNDEFINED'),
  1992.        decode(i.unique$, 0, 'NONUNIQUE', 1, 'UNIQUE', 'UNDEFINED'),
  1993.        ts.name, i.initrans, i.maxtrans,
  1994.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize,
  1995.        s.minexts, s.maxexts, s.extpct, i.pctfree$,
  1996.        i.blevel, i.leafcnt, i.distkey, i.lblkkey, i.dblkkey, i.clufac,
  1997.        decode(i.compress$, 2, 'DIRECT LOAD', 'VALID')
  1998. from sys.ts$ ts, sys.seg$ s, sys.user$ iu, sys.obj$ io, sys.ind$ i, sys.obj$ o
  1999. where o.owner# = userenv('SCHEMAID')
  2000.   and o.obj# = i.obj#
  2001.   and i.bo# = io.obj#
  2002.   and io.owner# = iu.user#
  2003.   and i.ts# = ts.ts#
  2004.   and i.file# = s.file#
  2005.   and i.block# = s.block#
  2006. /
  2007. comment on table USER_INDEXES is
  2008. 'Description of the user''s own indexes'
  2009. /
  2010. comment on column USER_INDEXES.STATUS is
  2011. 'Whether index is in Direct Load State or not'
  2012. /
  2013. comment on column USER_INDEXES.INDEX_NAME is
  2014. 'Name of the index'
  2015. /
  2016. comment on column USER_INDEXES.TABLE_OWNER is
  2017. 'Owner of the indexed object'
  2018. /
  2019. comment on column USER_INDEXES.TABLE_NAME is
  2020. 'Name of the indexed object'
  2021. /
  2022. comment on column USER_INDEXES.TABLE_TYPE is
  2023. 'Type of the indexed object'
  2024. /
  2025. comment on column USER_INDEXES.UNIQUENESS is
  2026. 'Uniqueness status of the index:  "UNIQUE" or "NONUNIQUE"'
  2027. /
  2028. comment on column USER_INDEXES.TABLESPACE_NAME is
  2029. 'Name of the tablespace containing the index'
  2030. /
  2031. comment on column USER_INDEXES.INI_TRANS is
  2032. 'Initial number of transactions'
  2033. /
  2034. comment on column USER_INDEXES.MAX_TRANS is
  2035. 'Maximum number of transactions'
  2036. /
  2037. comment on column USER_INDEXES.INITIAL_EXTENT is
  2038. 'Size of the initial extent in bytes'
  2039. /
  2040. comment on column USER_INDEXES.NEXT_EXTENT is
  2041. 'Size of secondary extents in bytes'
  2042. /
  2043. comment on column USER_INDEXES.MIN_EXTENTS is
  2044. 'Minimum number of extents allowed in the segment'
  2045. /
  2046. comment on column USER_INDEXES.MAX_EXTENTS is
  2047. 'Maximum number of extents allowed in the segment'
  2048. /
  2049. comment on column USER_INDEXES.PCT_INCREASE is
  2050. 'Percentage increase in extent size'
  2051. /
  2052. comment on column USER_INDEXES.PCT_FREE is
  2053. 'Minimum percentage of free space in a block'
  2054. /
  2055. comment on column USER_INDEXES.BLEVEL is
  2056. 'B-Tree level'
  2057. /
  2058. comment on column USER_INDEXES.LEAF_BLOCKS is
  2059. 'The number of leaf blocks in the index'
  2060. /
  2061. comment on column USER_INDEXES.DISTINCT_KEYS is
  2062. 'The number of distinct keys in the index'
  2063. /
  2064. comment on column USER_INDEXES.AVG_LEAF_BLOCKS_PER_KEY is
  2065. 'The average number of leaf blocks per key'
  2066. /
  2067. comment on column USER_INDEXES.AVG_DATA_BLOCKS_PER_KEY is
  2068. 'The average number of data blocks per key'
  2069. /
  2070. comment on column USER_INDEXES.CLUSTERING_FACTOR is
  2071. 'A measurement of the amount of (dis)order of the table this index is for'
  2072. /
  2073. drop public synonym USER_INDEXES
  2074. /
  2075. create public synonym USER_INDEXES for USER_INDEXES
  2076. /
  2077. drop public synonym IND
  2078. /
  2079. create public synonym IND for USER_INDEXES
  2080. /
  2081. grant select on USER_INDEXES to PUBLIC with grant option
  2082. /
  2083. remark
  2084. remark  This view does not include cluster indexes on clusters
  2085. remark  containing tables which are accessible to the user.
  2086. remark
  2087. create or replace view ALL_INDEXES
  2088.     (OWNER, INDEX_NAME, TABLE_OWNER, TABLE_NAME,
  2089.      TABLE_TYPE,
  2090.      UNIQUENESS,
  2091.      TABLESPACE_NAME, INI_TRANS, MAX_TRANS,
  2092.      INITIAL_EXTENT, NEXT_EXTENT, MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE,
  2093.      PCT_FREE, BLEVEL, LEAF_BLOCKS, DISTINCT_KEYS, AVG_LEAF_BLOCKS_PER_KEY,
  2094.      AVG_DATA_BLOCKS_PER_KEY, CLUSTERING_FACTOR, STATUS)
  2095.  as 
  2096. select u.name, o.name, iu.name, io.name, 'TABLE',
  2097.        decode(i.unique$, 0, 'NONUNIQUE', 1, 'UNIQUE', 'UNDEFINED'), 
  2098.        ts.name, i.initrans, i.maxtrans,
  2099.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize, 
  2100.        s.minexts, s.maxexts, s.extpct, i.pctfree$,
  2101.        i.blevel, i.leafcnt, i.distkey, i.lblkkey, i.dblkkey, i.clufac,
  2102.        decode(i.compress$, 2, 'DIRECT LOAD', 'VALID')
  2103. from sys.ts$ ts, sys.seg$ s, sys.user$ iu, sys.obj$ io, 
  2104.      sys.user$ u, sys.ind$ i, sys.obj$ o
  2105. where u.user# = o.owner#
  2106.   and o.obj# = i.obj#
  2107.   and i.bo# = io.obj#
  2108.   and io.owner# = iu.user# 
  2109.   and io.type = 2 /* tables */
  2110.   and i.ts# = ts.ts# 
  2111.   and i.file# = s.file#
  2112.   and i.block# = s.block# 
  2113.   and (io.owner# = userenv('SCHEMAID')
  2114.         or
  2115.        io.obj# in ( select obj#
  2116.                     from objauth$
  2117.                     where grantee# in ( select kzsrorol
  2118.                                         from x$kzsro
  2119.                                       )
  2120.                    )
  2121.         or
  2122.      exists (select null from v$enabledprivs
  2123.              where priv_number in (-45 /* LOCK ANY TABLE */,
  2124.                        -47 /* SELECT ANY TABLE */,
  2125.                        -48 /* INSERT ANY TABLE */,
  2126.                        -49 /* UPDATE ANY TABLE */,
  2127.                        -50 /* DELETE ANY TABLE */)
  2128.                  )
  2129.        )
  2130. /
  2131. comment on table ALL_INDEXES is
  2132. 'Descriptions of indexes on tables accessible to the user'
  2133. /
  2134. comment on column ALL_INDEXES.OWNER is
  2135. 'Username of the owner of the index'
  2136. /
  2137. comment on column ALL_INDEXES.STATUS is
  2138. 'Whether index is in Direct Load State or not'
  2139. /
  2140. comment on column ALL_INDEXES.INDEX_NAME is
  2141. 'Name of the index'
  2142. /
  2143. comment on column ALL_INDEXES.TABLE_OWNER is
  2144. 'Owner of the indexed object'
  2145. /
  2146. comment on column ALL_INDEXES.TABLE_NAME is
  2147. 'Name of the indexed object'
  2148. /
  2149. comment on column ALL_INDEXES.TABLE_TYPE is
  2150. 'Type of the indexed object'
  2151. /
  2152. comment on column ALL_INDEXES.UNIQUENESS is
  2153. 'Uniqueness status of the index:  "UNIQUE" or "NONUNIQUE"'
  2154. /
  2155. comment on column ALL_INDEXES.TABLESPACE_NAME is
  2156. 'Name of the tablespace containing the index'
  2157. /
  2158. comment on column ALL_INDEXES.INI_TRANS is
  2159. 'Initial number of transactions'
  2160. /
  2161. comment on column ALL_INDEXES.MAX_TRANS is
  2162. 'Maximum number of transactions'
  2163. /
  2164. comment on column ALL_INDEXES.INITIAL_EXTENT is
  2165. 'Size of the initial extent'
  2166. /
  2167. comment on column ALL_INDEXES.NEXT_EXTENT is
  2168. 'Size of secondary extents'
  2169. /
  2170. comment on column ALL_INDEXES.MIN_EXTENTS is
  2171. 'Minimum number of extents allowed in the segment'
  2172. /
  2173. comment on column ALL_INDEXES.MAX_EXTENTS is
  2174. 'Maximum number of extents allowed in the segment'
  2175. /
  2176. comment on column ALL_INDEXES.PCT_INCREASE is
  2177. 'Percentage increase in extent size'
  2178. /
  2179. comment on column ALL_INDEXES.PCT_FREE is
  2180. 'Minimum percentage of free space in a block'
  2181. /
  2182. comment on column ALL_INDEXES.BLEVEL is
  2183. 'B-Tree level'
  2184. /
  2185. comment on column ALL_INDEXES.LEAF_BLOCKS is
  2186. 'The number of leaf blocks in the index'
  2187. /
  2188. comment on column ALL_INDEXES.DISTINCT_KEYS is
  2189. 'The number of distinct keys in the index'
  2190. /
  2191. comment on column ALL_INDEXES.AVG_LEAF_BLOCKS_PER_KEY is
  2192. 'The average number of leaf blocks per key'
  2193. /
  2194. comment on column ALL_INDEXES.AVG_DATA_BLOCKS_PER_KEY is
  2195. 'The average number of data blocks per key'
  2196. /
  2197. comment on column ALL_INDEXES.CLUSTERING_FACTOR is
  2198. 'A measurement of the amount of (dis)order of the table this index is for'
  2199. /
  2200. drop public synonym ALL_INDEXES
  2201. /
  2202. create public synonym ALL_INDEXES for ALL_INDEXES
  2203. /
  2204. grant select on ALL_INDEXES to PUBLIC with grant option
  2205. /
  2206. create or replace view DBA_INDEXES
  2207.     (OWNER, INDEX_NAME, TABLE_OWNER, TABLE_NAME,
  2208.      TABLE_TYPE,
  2209.      UNIQUENESS,
  2210.      TABLESPACE_NAME, INI_TRANS, MAX_TRANS,
  2211.      INITIAL_EXTENT, NEXT_EXTENT,
  2212.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE, PCT_FREE, BLEVEL,
  2213.      LEAF_BLOCKS, DISTINCT_KEYS, AVG_LEAF_BLOCKS_PER_KEY,
  2214.      AVG_DATA_BLOCKS_PER_KEY, CLUSTERING_FACTOR, STATUS)
  2215. as
  2216. select u.name, o.name, iu.name, io.name,
  2217.        decode(io.type, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
  2218.                        4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE', 'UNDEFINED'),
  2219.        decode(i.unique$, 0, 'NONUNIQUE', 1, 'UNIQUE', 'UNDEFINED'),
  2220.        ts.name, i.initrans, i.maxtrans,
  2221.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize,
  2222.        s.minexts, s.maxexts, s.extpct, i.pctfree$,
  2223.        i.blevel, i.leafcnt, i.distkey, i.lblkkey, i.dblkkey, i.clufac,
  2224.        decode(i.compress$, 2, 'DIRECT LOAD', 'VALID')
  2225. from sys.ts$ ts, sys.seg$ s,
  2226.      sys.user$ iu, sys.obj$ io, sys.user$ u, sys.ind$ i, sys.obj$ o
  2227. where u.user# = o.owner#
  2228.   and o.obj# = i.obj#
  2229.   and i.bo# = io.obj#
  2230.   and io.owner# = iu.user#
  2231.   and i.ts# = ts.ts#
  2232.   and i.file# = s.file#
  2233.   and i.block# = s.block#
  2234. /
  2235. comment on table DBA_INDEXES is
  2236. 'Description for all indexes in the database'
  2237. /
  2238. comment on column DBA_INDEXES.STATUS is
  2239. 'Whether index is in Direct Load State or not'
  2240. /
  2241. comment on column DBA_INDEXES.OWNER is
  2242. 'Username of the owner of the index'
  2243. /
  2244. comment on column DBA_INDEXES.INDEX_NAME is
  2245. 'Name of the index'
  2246. /
  2247. comment on column DBA_INDEXES.TABLE_OWNER is
  2248. 'Owner of the indexed object'
  2249. /
  2250. comment on column DBA_INDEXES.TABLE_NAME is
  2251. 'Name of the indexed object'
  2252. /
  2253. comment on column DBA_INDEXES.TABLE_TYPE is
  2254. 'Type of the indexed object'
  2255. /
  2256. comment on column DBA_INDEXES.UNIQUENESS is
  2257. 'Uniqueness status of the index:  "UNIQUE" or "NONUNIQUE"'
  2258. /
  2259. comment on column DBA_INDEXES.TABLESPACE_NAME is
  2260. 'Name of the tablespace containing the index'
  2261. /
  2262. comment on column DBA_INDEXES.INI_TRANS is
  2263. 'Initial number of transactions'
  2264. /
  2265. comment on column DBA_INDEXES.MAX_TRANS is
  2266. 'Maximum number of transactions'
  2267. /
  2268. comment on column DBA_INDEXES.INITIAL_EXTENT is
  2269. 'Size of the initial extent'
  2270. /
  2271. comment on column DBA_INDEXES.NEXT_EXTENT is
  2272. 'Size of secondary extents'
  2273. /
  2274. comment on column DBA_INDEXES.MIN_EXTENTS is
  2275. 'Minimum number of extents allowed in the segment'
  2276. /
  2277. comment on column DBA_INDEXES.MAX_EXTENTS is
  2278. 'Maximum number of extents allowed in the segment'
  2279. /
  2280. comment on column DBA_INDEXES.PCT_INCREASE is
  2281. 'Percentage increase in extent size'
  2282. /
  2283. comment on column DBA_INDEXES.PCT_FREE is
  2284. 'Minimum percentage of free space in a block'
  2285. /
  2286. comment on column DBA_INDEXES.BLEVEL is
  2287. 'B-Tree level'
  2288. /
  2289. comment on column DBA_INDEXES.LEAF_BLOCKS is
  2290. 'The number of leaf blocks in the index'
  2291. /
  2292. comment on column DBA_INDEXES.DISTINCT_KEYS is
  2293. 'The number of distinct keys in the index'
  2294. /
  2295. comment on column DBA_INDEXES.AVG_LEAF_BLOCKS_PER_KEY is
  2296. 'The average number of leaf blocks per key'
  2297. /
  2298. comment on column DBA_INDEXES.AVG_DATA_BLOCKS_PER_KEY is
  2299. 'The average number of data blocks per key'
  2300. /
  2301. comment on column DBA_INDEXES.CLUSTERING_FACTOR is
  2302. 'A measurement of the amount of (dis)order of the table this index is for'
  2303. /
  2304. remark
  2305. remark  FAMILY "IND_COLUMNS"
  2306. remark  Displays information on which columns are contained in which
  2307. remark  indexes
  2308. remark
  2309. create or replace view USER_IND_COLUMNS
  2310.     (INDEX_NAME, TABLE_NAME, COLUMN_NAME, COLUMN_POSITION, COLUMN_LENGTH)
  2311. as
  2312. select idx.name, base.name, 
  2313.        c.name, ic.pos#, c.length
  2314. from sys.col$ c, sys.obj$ idx, sys.obj$ base, sys.icol$ ic
  2315. where base.obj# = c.obj#
  2316.   and ic.bo# = base.obj#
  2317.   and ic.col# = c.col#
  2318.   and (base.owner# = userenv('SCHEMAID') or idx.owner# = userenv('SCHEMAID'))
  2319.   and ic.obj# = idx.obj#
  2320. /
  2321. comment on table USER_IND_COLUMNS is
  2322. 'COLUMNs comprising user''s INDEXes or on user''s TABLES'
  2323. /
  2324. comment on column USER_IND_COLUMNS.INDEX_NAME is
  2325. 'Index name'
  2326. /
  2327. comment on column USER_IND_COLUMNS.TABLE_NAME is
  2328. 'Table or cluster name'
  2329. /
  2330. comment on column USER_IND_COLUMNS.COLUMN_NAME is
  2331. 'Column name'
  2332. /
  2333. comment on column USER_IND_COLUMNS.COLUMN_POSITION is
  2334. 'Position of column within index'
  2335. /
  2336. comment on column USER_IND_COLUMNS.COLUMN_LENGTH is
  2337. 'Indexed length of the column'
  2338. /
  2339. drop public synonym USER_IND_COLUMNS
  2340. /
  2341. create public synonym USER_IND_COLUMNS for USER_IND_COLUMNS
  2342. /
  2343. grant select on USER_IND_COLUMNS to PUBLIC with grant option
  2344. /
  2345. create or replace view ALL_IND_COLUMNS
  2346.     (INDEX_OWNER, INDEX_NAME,
  2347.      TABLE_OWNER, TABLE_NAME,
  2348.      COLUMN_NAME, COLUMN_POSITION, COLUMN_LENGTH)
  2349. as
  2350. select io.name, idx.name, bo.name, base.name, 
  2351.        c.name, ic.pos#, c.length
  2352. from sys.col$ c, sys.obj$ idx, sys.obj$ base, sys.icol$ ic,
  2353.      sys.user$ io, sys.user$ bo
  2354. where base.obj# = c.obj#
  2355.   and ic.col# = c.col#
  2356.   and ic.bo# = base.obj#
  2357.   and io.user# = idx.owner#
  2358.   and bo.user# = base.owner#
  2359.   and ic.obj# = idx.obj#
  2360.   and (idx.owner# = userenv('SCHEMAID') or
  2361.        base.owner# = userenv('SCHEMAID')
  2362.        or
  2363.        base.obj# in ( select obj#
  2364.                      from sys.objauth$
  2365.                      where grantee# in ( select kzsrorol
  2366.                                          from x$kzsro
  2367.                                        )
  2368.                    )
  2369.         or
  2370.      exists (select null from v$enabledprivs
  2371.              where priv_number in (-45 /* LOCK ANY TABLE */,
  2372.                        -47 /* SELECT ANY TABLE */,
  2373.                        -48 /* INSERT ANY TABLE */,
  2374.                        -49 /* UPDATE ANY TABLE */,
  2375.                        -50 /* DELETE ANY TABLE */)
  2376.                  )
  2377.        )
  2378. /
  2379. comment on table ALL_IND_COLUMNS is
  2380. 'COLUMNs comprising INDEXes on accessible TABLES'
  2381. /
  2382. comment on column ALL_IND_COLUMNS.INDEX_OWNER is
  2383. 'Index owner'
  2384. /
  2385. comment on column ALL_IND_COLUMNS.INDEX_NAME is
  2386. 'Index name'
  2387. /
  2388. comment on column ALL_IND_COLUMNS.TABLE_OWNER is
  2389. 'Table or cluster owner'
  2390. /
  2391. comment on column ALL_IND_COLUMNS.TABLE_NAME is
  2392. 'Table or cluster name'
  2393. /
  2394. comment on column ALL_IND_COLUMNS.COLUMN_NAME is
  2395. 'Column name'
  2396. /
  2397. comment on column ALL_IND_COLUMNS.COLUMN_POSITION is
  2398. 'Position of column within index'
  2399. /
  2400. comment on column ALL_IND_COLUMNS.COLUMN_LENGTH is
  2401. 'Indexed length of the column'
  2402. /
  2403. drop public synonym ALL_IND_COLUMNS
  2404. /
  2405. create public synonym ALL_IND_COLUMNS for ALL_IND_COLUMNS
  2406. /
  2407. grant select on ALL_IND_COLUMNS to PUBLIC with grant option
  2408. /
  2409. create or replace view DBA_IND_COLUMNS
  2410.     (INDEX_OWNER, INDEX_NAME,
  2411.      TABLE_OWNER, TABLE_NAME,
  2412.      COLUMN_NAME, COLUMN_POSITION, COLUMN_LENGTH)
  2413. as
  2414. select io.name, idx.name, bo.name, base.name, 
  2415.        c.name, ic.pos#, c.length
  2416. from sys.col$ c, sys.obj$ idx, sys.obj$ base, sys.icol$ ic,
  2417.      sys.user$ io, sys.user$ bo
  2418. where base.obj# = c.obj#
  2419.   and ic.col# = c.col#
  2420.   and ic.bo# = base.obj#
  2421.   and io.user# = idx.owner#
  2422.   and bo.user# = base.owner#
  2423.   and ic.obj# = idx.obj#
  2424. /
  2425. comment on table DBA_IND_COLUMNS is
  2426. 'COLUMNs comprising INDEXes on all TABLEs and CLUSTERs'
  2427. /
  2428. comment on column DBA_IND_COLUMNS.INDEX_OWNER is
  2429. 'Index owner'
  2430. /
  2431. comment on column DBA_IND_COLUMNS.INDEX_NAME is
  2432. 'Index name'
  2433. /
  2434. comment on column DBA_IND_COLUMNS.TABLE_OWNER is
  2435. 'Table or cluster owner'
  2436. /
  2437. comment on column DBA_IND_COLUMNS.TABLE_NAME is
  2438. 'Table or cluster name'
  2439. /
  2440. comment on column DBA_IND_COLUMNS.COLUMN_NAME is
  2441. 'Column name'
  2442. /
  2443. comment on column DBA_IND_COLUMNS.COLUMN_POSITION is
  2444. 'Position of column within index'
  2445. /
  2446. comment on column DBA_IND_COLUMNS.COLUMN_LENGTH is
  2447. 'Indexed length of the column'
  2448. /
  2449. create or replace view INDEX_STATS as
  2450.  select    kdxstrot+1    height, 
  2451.     s.blocks,
  2452.     o.name,
  2453.            kdxstlrw     lf_rows,
  2454.     kdxstlbk    lf_blks,
  2455.     kdxstlln    lf_rows_len,
  2456.     kdxstlub    lf_blk_len,
  2457.            kdxstbrw     br_rows,
  2458.     kdxstbbk    br_blks,
  2459.     kdxstbln    br_rows_len,
  2460.     kdxstbub    br_blk_len,
  2461.     kdxstdrw    del_lf_rows,
  2462.     kdxstdln    del_lf_rows_len,
  2463.     kdxstdis    distinct_keys,
  2464.     kdxstmrl    most_repeated_key,
  2465.     kdxstlbk*kdxstlub+kdxstbbk*kdxstbub    btree_space,
  2466.     kdxstlln+kdxstbln            used_space,
  2467.     ceil(((kdxstlln+kdxstbln)*100)/
  2468.     (kdxstlbk*kdxstlub+kdxstbbk*kdxstbub))
  2469.                         pct_used,    
  2470.     kdxstlrw/decode(kdxstdis, 0, 1, kdxstdis) rows_per_key,
  2471.     kdxstrot+1+(kdxstlrw+kdxstdis)/(decode(kdxstdis, 0, 1, kdxstdis)*2)
  2472.                         blks_gets_per_access
  2473.   from obj$ o, ind$ i, seg$ s, x$kdxst
  2474.  where kdxstfil = s.file#
  2475.   and  kdxstblk = s.block#
  2476.   and  s.file#  = i.file#
  2477.   and  s.block# = i.block#
  2478.   and  i.obj#   = o.obj#
  2479. /
  2480. comment on table INDEX_STATS is
  2481. 'statistics on the b-tree'
  2482. /
  2483. comment on column index_stats.height is 
  2484. 'height of the b-tree'
  2485. /
  2486. comment on column index_stats.blocks is
  2487. 'blocks allocated to the segment'
  2488. /
  2489. comment on column index_stats.name is
  2490. 'name of the index'
  2491. /
  2492. comment on column index_stats.lf_rows is
  2493. 'number of leaf rows (values in the index)'
  2494. /
  2495. comment on column index_stats.lf_blks is
  2496. 'number of leaf blocks in the b-tree'
  2497. /
  2498. comment on column index_stats.lf_rows_len is
  2499. 'sum of the lengths of all the leaf rows'
  2500. /
  2501. comment on column index_stats.lf_blk_len is
  2502. 'useable space in a leaf block'
  2503. /
  2504. comment on column index_stats.br_rows is
  2505. 'number of branch rows'
  2506. /
  2507. comment on column index_stats.br_blks is
  2508. 'number of branch blocks in the b-tree'
  2509. /
  2510. comment on column index_stats.br_rows_len is
  2511. 'sum of the lengths of all the branch blocks in the b-tree'
  2512. /
  2513. comment on column index_stats.br_blk_len is
  2514. 'useable space in a branch block'
  2515. /
  2516. comment on column index_stats.del_lf_rows is
  2517. 'number of deleted leaf rows in the index'
  2518. /
  2519. comment on column index_stats.del_lf_rows_len is
  2520. 'total length of all deleted rows in the index'
  2521. /
  2522. comment on column index_stats.distinct_keys is
  2523. 'number of distinct keys in the index'
  2524. /
  2525. comment on column index_stats.most_repeated_key is
  2526. 'how many times the most repeated key is repeated'
  2527. /
  2528. comment on column index_stats.btree_space is
  2529. 'total space currently allocated in the b-tree'
  2530. /
  2531. comment on column index_stats.used_space is
  2532. 'total space that is currently being used in the b-tree'
  2533. /
  2534. comment on column index_stats.pct_used is
  2535. 'percent of space allocated in the b-tree that is being used'
  2536. /
  2537. comment on column index_stats.rows_per_key is
  2538. 'average number of rows per distinct key'
  2539. /
  2540. comment on column index_stats.blks_gets_per_access is
  2541. 'Expected number of consistent mode block gets per row. This assumes that a row chosen at random from the table is being searched for using the index'
  2542. /
  2543. drop public synonym INDEX_STATS
  2544. /
  2545. create public synonym INDEX_STATS for INDEX_STATS
  2546. /
  2547. grant select on INDEX_STATS to public with grant option
  2548. /
  2549. create or replace view INDEX_HISTOGRAM as
  2550.  select hist.indx * power(2, stats.kdxstscl-4)    repeat_count,
  2551.     hist.kdxhsval                keys_with_repeat_count
  2552.     from  x$kdxst stats, x$kdxhs hist
  2553. /
  2554. comment on table INDEX_HISTOGRAM is
  2555. 'statistics on keys with repeat count'
  2556. /
  2557. comment on column index_histogram.repeat_count is
  2558. 'number of times that a key is repeated'
  2559. /
  2560. comment on column index_histogram.keys_with_repeat_count is
  2561. 'number of keys that are repeated REPEAT_COUNT times'
  2562. /
  2563. drop public synonym INDEX_HISTOGRAM
  2564. /
  2565. create public synonym INDEX_HISTOGRAM for INDEX_HISTOGRAM
  2566. /
  2567. grant select on INDEX_HISTOGRAM to public with grant option
  2568. /
  2569. remark
  2570. remark  FAMILY "OBJECTS"
  2571. remark  List of objects, including creation and modify times.
  2572. remark
  2573. create or replace view USER_OBJECTS
  2574.     (OBJECT_NAME, OBJECT_ID, OBJECT_TYPE,
  2575.      CREATED, LAST_DDL_TIME, TIMESTAMP, STATUS)
  2576. as
  2577. select o.name, o.obj#,
  2578.        decode(o.type, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
  2579.                       4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE', 
  2580.                       7, 'PROCEDURE', 8, 'FUNCTION', 9, 'PACKAGE',
  2581.                       11, 'PACKAGE BODY', 12, 'TRIGGER', 'UNDEFINED'),
  2582.        o.ctime, o.mtime,
  2583.        to_char(o.stime, 'YYYY-MM-DD:HH24:MI:SS'),
  2584.        decode(o.status, 0, 'N/A', 1, 'VALID', 'INVALID')
  2585. from sys.obj$ o
  2586. where o.owner# = userenv('SCHEMAID')
  2587.   and o.linkname is null
  2588.   and o.type != 10
  2589. union all
  2590. select l.name, to_number(null),
  2591.        'DATABASE LINK',
  2592.        l.ctime, to_date(null), NULL, 'VALID'
  2593. from sys.link$ l
  2594. where l.owner# = userenv('SCHEMAID')
  2595. /
  2596. comment on table USER_OBJECTS is
  2597. 'Objects owned by the user'
  2598. /
  2599. comment on column USER_OBJECTS.OBJECT_NAME is
  2600. 'Name of the object'
  2601. /
  2602. comment on column USER_OBJECTS.OBJECT_ID is
  2603. 'Object number of the object'
  2604. /
  2605. comment on column USER_OBJECTS.OBJECT_TYPE is
  2606. 'Type of the object'
  2607. /
  2608. comment on column USER_OBJECTS.CREATED is
  2609. 'Timestamp for the creation of the object'
  2610. /
  2611. comment on column USER_OBJECTS.LAST_DDL_TIME is
  2612. 'Timestamp for the last DDL change (including GRANT and REVOKE) to the object'
  2613. /
  2614. comment on column USER_OBJECTS.TIMESTAMP is
  2615. 'Timestamp for the specification of the object'
  2616. /
  2617. comment on column USER_OBJECTS.STATUS is
  2618. 'Status of the object'
  2619. /
  2620. drop public synonym USER_OBJECTS
  2621. /
  2622. create public synonym USER_OBJECTS for USER_OBJECTS
  2623. /
  2624. drop public synonym OBJ
  2625. /
  2626. create public synonym OBJ for USER_OBJECTS
  2627. /
  2628. grant select on USER_OBJECTS to PUBLIC with grant option
  2629. /
  2630. create or replace view ALL_OBJECTS
  2631.     (OWNER, OBJECT_NAME, OBJECT_ID, OBJECT_TYPE,
  2632.      CREATED, LAST_DDL_TIME, TIMESTAMP, STATUS)
  2633. as
  2634. select u.name, o.name, o.obj#,
  2635.        decode(o.type, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
  2636.                       4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE', 
  2637.                       7, 'PROCEDURE', 8, 'FUNCTION', 9, 'PACKAGE',
  2638.                       11, 'PACKAGE BODY', 12, 'TRIGGER', 'UNDEFINED'),
  2639.        o.ctime, o.mtime,
  2640.        to_char(o.stime, 'YYYY-MM-DD:HH24:MI:SS'),
  2641.        decode(o.status, 0, 'N/A', 1, 'VALID', 'INVALID')
  2642. from sys.obj$ o, sys.user$ u
  2643. where o.owner# = u.user#
  2644.   and o.linkname is null
  2645.   and o.type != 10
  2646.   and
  2647.   (
  2648.     o.owner# in (userenv('SCHEMAID'), 1 /* PUBLIC */)
  2649.     or
  2650.     (
  2651.       o.type != 11 /* EXECUTE priv does not let user see pkg body */
  2652.       and
  2653.       o.obj# in (select obj# from sys.objauth$
  2654.                  where grantee# in (select kzsrorol from x$kzsro)
  2655.                    and privilege# in (3 /* DELETE */,   6 /* INSERT */,
  2656.                                       7 /* LOCK */,     9 /* SELECT */,
  2657.                                       10 /* UPDATE */, 12 /* EXECUTE */))
  2658.     )
  2659.     or
  2660.     (
  2661.        o.type in (7, 8, 9) /* prc, fcn, pkg */
  2662.        and
  2663.        exists (select null from v$enabledprivs
  2664.            where priv_number = -144 /* EXECUTE ANY PROCEDURE */)
  2665.     )
  2666.     or
  2667.     (
  2668.        o.type in (2, 4, 5) /* table, view, synonym */
  2669.        and
  2670.        exists (select null from v$enabledprivs
  2671.                where priv_number in (-45 /* LOCK ANY TABLE */,
  2672.                      -47 /* SELECT ANY TABLE */,
  2673.                      -48 /* INSERT ANY TABLE */,
  2674.                      -49 /* UPDATE ANY TABLE */,
  2675.                      -50 /* DELETE ANY TABLE */)
  2676.                )
  2677.     )
  2678.     or
  2679.     ( o.type = 6 /* sequence */
  2680.       and
  2681.       exists (select null from v$enabledprivs
  2682.               where priv_number = -109 /* SELECT ANY SEQUENCE */)
  2683.     )
  2684.   )
  2685. /
  2686. comment on table ALL_OBJECTS is
  2687. 'Objects accessible to the user'
  2688. /
  2689. comment on column ALL_OBJECTS.OWNER is
  2690. 'Username of the owner of the object'
  2691. /
  2692. comment on column ALL_OBJECTS.OBJECT_NAME is
  2693. 'Name of the object'
  2694. /
  2695. comment on column ALL_OBJECTS.OBJECT_ID is
  2696. 'Object number of the object'
  2697. /
  2698. comment on column ALL_OBJECTS.OBJECT_TYPE is
  2699. 'Type of the object'
  2700. /
  2701. comment on column ALL_OBJECTS.CREATED is
  2702. 'Timestamp for the creation of the object'
  2703. /
  2704. comment on column ALL_OBJECTS.LAST_DDL_TIME is
  2705. 'Timestamp for the last DDL change (including GRANT and REVOKE) to the object'
  2706. /
  2707. comment on column ALL_OBJECTS.TIMESTAMP is
  2708. 'Timestamp for the specification of the object'
  2709. /
  2710. comment on column ALL_OBJECTS.STATUS is
  2711. 'Status of the object'
  2712. /
  2713. drop public synonym ALL_OBJECTS
  2714. /
  2715. create public synonym ALL_OBJECTS for ALL_OBJECTS
  2716. /
  2717. grant select on ALL_OBJECTS to PUBLIC with grant option
  2718. /
  2719. create or replace view DBA_OBJECTS
  2720.     (OWNER, OBJECT_NAME, OBJECT_ID, OBJECT_TYPE,
  2721.      CREATED, LAST_DDL_TIME, TIMESTAMP, STATUS)
  2722. as
  2723. select u.name, o.name, o.obj#,
  2724.        decode(o.type, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
  2725.                       4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE', 
  2726.                       7, 'PROCEDURE', 8, 'FUNCTION', 9, 'PACKAGE',
  2727.                       11, 'PACKAGE BODY', 12, 'TRIGGER', 'UNDEFINED'),
  2728.        o.ctime, o.mtime,
  2729.        to_char(o.stime, 'YYYY-MM-DD:HH24:MI:SS'),
  2730.        decode(o.status, 0, 'N/A', 1, 'VALID', 'INVALID')
  2731. from sys.obj$ o, sys.user$ u
  2732. where o.owner# = u.user#
  2733.   and o.linkname is null
  2734.   and o.type != 10 and o.name != '_NEXT_OBJECT'
  2735.   and o.name != '_default_auditing_options_'
  2736. union all
  2737. select u.name, l.name, to_number(null),
  2738.        'DATABASE LINK',
  2739.        l.ctime, to_date(null), NULL, 'VALID'
  2740. from sys.link$ l, sys.user$ u
  2741. where l.owner# = u.user#
  2742. /
  2743. comment on table DBA_OBJECTS is
  2744. 'All objects in the database'
  2745. /
  2746. comment on column DBA_OBJECTS.OWNER is
  2747. 'Username of the owner of the object'
  2748. /
  2749. comment on column DBA_OBJECTS.OBJECT_NAME is
  2750. 'Name of the object'
  2751. /
  2752. comment on column DBA_OBJECTS.OBJECT_ID is
  2753. 'Object number of the object'
  2754. /
  2755. comment on column DBA_OBJECTS.OBJECT_TYPE is
  2756. 'Type of the object'
  2757. /
  2758. comment on column DBA_OBJECTS.CREATED is
  2759. 'Timestamp for the creation of the object'
  2760. /
  2761. comment on column DBA_OBJECTS.LAST_DDL_TIME is
  2762. 'Timestamp for the last DDL change (including GRANT and REVOKE) to the object'
  2763. /
  2764. comment on column DBA_OBJECTS.TIMESTAMP is
  2765. 'Timestamp for the specification of the object'
  2766. /
  2767. comment on column DBA_OBJECTS.STATUS is
  2768. 'Status of the object'
  2769. /
  2770. remark
  2771. remark  FAMILY "ROLLBACK_SEGS"
  2772. remark  CREATE ROLLBACK SEGMENT parameters.
  2773. remark  This family has a DBA member only.
  2774. remark
  2775. create or replace view DBA_ROLLBACK_SEGS
  2776.     (SEGMENT_NAME, OWNER, TABLESPACE_NAME, SEGMENT_ID, FILE_ID, BLOCK_ID,
  2777.      INITIAL_EXTENT, NEXT_EXTENT,
  2778.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE,
  2779.      STATUS, INSTANCE_NUM)
  2780. as
  2781. select un.name, decode(un.user#,1,'PUBLIC','SYS'),
  2782.        ts.name, un.us#, un.file#, un.block#,
  2783.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize,
  2784.        s.minexts, s.maxexts, s.extpct,
  2785.        decode(un.status$, 1, 'INVALID', 2, 'OFFLINE', 3, 'ONLINE',
  2786.                           4, 'UNDEFINED', 5, 'NEEDS RECOVERY', 
  2787.                           6, 'PARTLY AVAILABLE', 'UNDEFINED'),
  2788.        decode(un.inst#, 0, NULL, un.inst#)
  2789. from sys.undo$ un, sys.seg$ s, sys.ts$ ts
  2790. where un.file# = s.file# (+)
  2791.   and un.block# = s.block# (+)
  2792.   and s.type = 1
  2793.   and s.ts# = ts.ts#
  2794. /
  2795. comment on table DBA_ROLLBACK_SEGS is
  2796. 'Description of rollback segments'
  2797. /
  2798. comment on column DBA_ROLLBACK_SEGS.SEGMENT_NAME is
  2799. 'Name of the rollback segment'
  2800. /
  2801. comment on column DBA_ROLLBACK_SEGS.OWNER is
  2802. 'Owner of the rollback segment'
  2803. /
  2804. comment on column DBA_ROLLBACK_SEGS.TABLESPACE_NAME is
  2805. 'Name of the tablespace containing the rollback segment'
  2806. /
  2807. comment on column DBA_ROLLBACK_SEGS.SEGMENT_ID is
  2808. 'ID number of the rollback segment'
  2809. /
  2810. comment on column DBA_ROLLBACK_SEGS.FILE_ID is
  2811. 'ID number of the file containing the segment header'
  2812. /
  2813. comment on column DBA_ROLLBACK_SEGS.BLOCK_ID is
  2814. 'ID number of the block containing the segment header'
  2815. /
  2816. comment on column DBA_ROLLBACK_SEGS.INITIAL_EXTENT is
  2817. 'Initial extent size in bytes'
  2818. /
  2819. comment on column DBA_ROLLBACK_SEGS.NEXT_EXTENT is
  2820. 'Secondary extent size in bytes'
  2821. /
  2822. comment on column DBA_ROLLBACK_SEGS.MIN_EXTENTS is
  2823. 'Minimum number of extents'
  2824. /
  2825. comment on column DBA_ROLLBACK_SEGS.MAX_EXTENTS is
  2826. 'Maximum number of extents'
  2827. /
  2828. comment on column DBA_ROLLBACK_SEGS.PCT_INCREASE is
  2829. 'Percent increase for extent size'
  2830. /
  2831. comment on column DBA_ROLLBACK_SEGS.STATUS is
  2832. 'Rollback segment status'
  2833. /   
  2834. comment on column DBA_ROLLBACK_SEGS.INSTANCE_NUM is
  2835. 'Rollback segment owning parallel server instance number'
  2836. /
  2837. remark
  2838. remark  FAMILY "ROLE GRANTS"
  2839. remark  
  2840. remark
  2841. create or replace view USER_ROLE_PRIVS
  2842.     (USERNAME, GRANTED_ROLE, ADMIN_OPTION, DEFAULT_ROLE, OS_GRANTED)
  2843. as
  2844. select decode(sa.grantee#, 1, 'PUBLIC', u1.name), u2.name,
  2845.        decode(min(option$), 1, 'YES', 'NO'),
  2846.        decode(min(u1.defrole), 0, 'NO', 1, 'YES', 
  2847.               2, decode(min(ud.role#),null,'NO','YES'), 
  2848.               3, decode(min(ud.role#),null,'YES','NO'), 'NO'), 'NO'
  2849. from sysauth$ sa,defrole$ ud, user$ u1, user$ u2
  2850. where sa.grantee# in (userenv('SCHEMAID'),1) and sa.grantee#=ud.user#(+)
  2851.   and sa.privilege#=ud.role#(+) and u1.user#=sa.grantee#
  2852.   and u2.user#=sa.privilege#
  2853. group by decode(sa.grantee#,1,'PUBLIC',u1.name),u2.name
  2854. union
  2855. select user,u.name,decode(kzdosadm,'A','YES','NO'), 
  2856.        decode(kzdosdef,'Y','YES','NO'), 'YES'
  2857.  from sys.user$ u,x$kzdos
  2858. where u.user#=x$kzdos.kzdosrol
  2859. /
  2860. comment on table USER_ROLE_PRIVS is
  2861. 'Roles granted to current user'
  2862. /
  2863. comment on column USER_ROLE_PRIVS.USERNAME is
  2864. 'User Name or PUBLIC'
  2865. /
  2866. comment on column USER_ROLE_PRIVS.GRANTED_ROLE is
  2867. 'Granted role name'
  2868. /
  2869. comment on column USER_ROLE_PRIVS.ADMIN_OPTION is
  2870. 'Grant was with the ADMIN option'
  2871. /
  2872. comment on column USER_ROLE_PRIVS.DEFAULT_ROLE is
  2873. 'Role is designated as a DEFAULT ROLE for the user'
  2874. /
  2875. comment on column USER_ROLE_PRIVS.OS_GRANTED is
  2876. 'Role is granted via the operating system (using OS_ROLES = TRUE)'
  2877. /
  2878. drop public synonym USER_ROLE_PRIVS
  2879. /
  2880. create public synonym USER_ROLE_PRIVS for USER_ROLE_PRIVS
  2881. /
  2882. grant select on USER_ROLE_PRIVS to PUBLIC with grant option
  2883. /
  2884. create or replace view DBA_ROLE_PRIVS
  2885.     (GRANTEE, GRANTED_ROLE, ADMIN_OPTION, DEFAULT_ROLE)
  2886. as
  2887. select decode(sa.grantee#, 1, 'PUBLIC', u1.name), u2.name,
  2888.        decode(min(option$), 1, 'YES', 'NO'),
  2889.        decode(min(u1.defrole), 0, 'NO', 1, 'YES', 
  2890.               2, decode(min(ud.role#),null,'NO','YES'), 
  2891.               3, decode(min(ud.role#),null,'YES','NO'), 'NO')
  2892. from sysauth$ sa,defrole$ ud, user$ u1, user$ u2
  2893. where sa.grantee#=ud.user#(+)
  2894.   and sa.privilege#=ud.role#(+) and u1.user#=sa.grantee#
  2895.   and u2.user#=sa.privilege#
  2896. group by decode(sa.grantee#,1,'PUBLIC',u1.name),u2.name
  2897. /
  2898. comment on table DBA_ROLE_PRIVS is
  2899. 'Roles granted to users and roles'
  2900. /
  2901. comment on column DBA_ROLE_PRIVS.GRANTEE is
  2902. 'Grantee Name, User or Role receiving the grant'
  2903. /
  2904. comment on column DBA_ROLE_PRIVS.GRANTED_ROLE is
  2905. 'Granted role name'
  2906. /
  2907. comment on column DBA_ROLE_PRIVS.ADMIN_OPTION is
  2908. 'Grant was with the ADMIN option'
  2909. /
  2910. comment on column DBA_ROLE_PRIVS.DEFAULT_ROLE is
  2911. 'Role is designated as a DEFAULT ROLE for the user'
  2912. /
  2913. remark
  2914. remark  FAMILY "SYS GRANTS"
  2915. remark  
  2916. remark
  2917. create or replace view USER_SYS_PRIVS
  2918.     (USERNAME, PRIVILEGE, ADMIN_OPTION)
  2919. as
  2920. select decode(sa.grantee#,1,'PUBLIC',user),spm.name,
  2921.        decode(min(option$),1,'YES','NO')
  2922. from  sys.system_privilege_map spm, sys.sysauth$ sa
  2923. where (sa.grantee#=userenv('SCHEMAID') or sa.grantee#=1)
  2924.   and sa.privilege#=spm.privilege
  2925. group by decode(sa.grantee#,1,'PUBLIC',user),spm.name
  2926. /
  2927. comment on table USER_SYS_PRIVS is
  2928. 'System privileges granted to current user'
  2929. /
  2930. comment on column USER_SYS_PRIVS.USERNAME is
  2931. 'User Name or PUBLIC'
  2932. /
  2933. comment on column USER_SYS_PRIVS.PRIVILEGE is
  2934. 'System privilege'
  2935. /
  2936. comment on column USER_SYS_PRIVS.ADMIN_OPTION is
  2937. 'Grant was with the ADMIN option'
  2938. /
  2939. drop public synonym USER_SYS_PRIVS
  2940. /
  2941. create public synonym USER_SYS_PRIVS for USER_SYS_PRIVS
  2942. /
  2943. grant select on USER_SYS_PRIVS to PUBLIC with grant option
  2944. /
  2945. create or replace view DBA_SYS_PRIVS
  2946.     (GRANTEE, PRIVILEGE, ADMIN_OPTION)
  2947. as
  2948. select u.name,spm.name,decode(min(option$),1,'YES','NO')
  2949. from  sys.system_privilege_map spm, sys.sysauth$ sa, user$ u
  2950. where sa.grantee#=u.user# and sa.privilege#=spm.privilege
  2951. group by u.name,spm.name
  2952. /
  2953. comment on table DBA_SYS_PRIVS is
  2954. 'System privileges granted to users and roles'
  2955. /
  2956. comment on column DBA_SYS_PRIVS.GRANTEE is
  2957. 'Grantee Name, User or Role receiving the grant'
  2958. /
  2959. comment on column DBA_SYS_PRIVS.PRIVILEGE is
  2960. 'System privilege'
  2961. /
  2962. comment on column DBA_SYS_PRIVS.ADMIN_OPTION is
  2963. 'Grant was with the ADMIN option'
  2964. /
  2965. remark  FAMILY "SEGMENTS"
  2966. remark  Storage for all types of segments
  2967. remark  This family has no ALL member.
  2968. remark  define SYS_OBJECTS for use by segments views
  2969. create or replace view SYS_OBJECTS
  2970.     (OBJECT_TYPE, OBJECT_TYPE_ID, SEGMENT_TYPE_ID,
  2971.      OBJECT_ID, HEADER_FILE, HEADER_BLOCK)
  2972. as
  2973. select 'TABLE', 2, 5,
  2974.        t.obj#, t.file#, t.block#
  2975. from sys.tab$ t
  2976. where t.clu# is null  /* exclude clustered tables */
  2977. union all
  2978. select 'CLUSTER', 3, 5,
  2979.        c.obj#, c.file#, c.block#
  2980. from sys.clu$ c
  2981. union all
  2982. select 'INDEX', 1, 6,
  2983.        i.obj#, i.file#, i.block#
  2984. from sys.ind$ i
  2985. /
  2986. create or replace view USER_SEGMENTS
  2987.     (SEGMENT_NAME,
  2988.      SEGMENT_TYPE,
  2989.      TABLESPACE_NAME,
  2990.      BYTES, BLOCKS, EXTENTS, 
  2991.      INITIAL_EXTENT, NEXT_EXTENT, 
  2992.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE, FREELISTS, FREELIST_GROUPS)
  2993. as
  2994. select o.name,
  2995.        so.object_type,
  2996.        ts.name,
  2997.        s.blocks * ts.blocksize, s.blocks, s.extents, 
  2998.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize, s.minexts, 
  2999.        s.maxexts, s.extpct,
  3000.        decode(s.lists, 0, 1, s.lists), decode(s.groups, 0, 1, s.groups)
  3001. from sys.obj$ o, sys.ts$ ts, sys.sys_objects so, sys.seg$ s
  3002. where s.file# = so.header_file
  3003.   and s.block# = so.header_block
  3004.   and s.ts# = ts.ts#
  3005.   and o.obj# = so.object_id
  3006.   and o.owner# = userenv('SCHEMAID')
  3007.   and s.type = so.segment_type_id
  3008.   and o.type = so.object_type_id
  3009. union all
  3010. select un.name,
  3011.        'ROLLBACK',
  3012.        ts.name,
  3013.        s.blocks * ts.blocksize, s.blocks, s.extents,
  3014.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize, s.minexts, 
  3015.        s.maxexts, s.extpct,
  3016.        decode(s.lists, 0, 1, s.lists), decode(s.groups, 0, 1, s.groups)
  3017. from sys.ts$ ts, sys.undo$ un, sys.seg$ s
  3018. where s.file# = un.file#
  3019.   and s.block# = un.block#
  3020.   and s.ts# = ts.ts#
  3021.   and s.user# = userenv('SCHEMAID')
  3022.   and s.type = 1
  3023.   and un.status$ != 1  
  3024. union all
  3025. select to_char(s.file#) || '.' || to_char(s.block#),
  3026.        decode(s.type, 2, 'DEFERRED ROLLBACK', 3, 'TEMPORARY',
  3027.                       4, 'CACHE', 'UNDEFINED'),
  3028.        ts.name,
  3029.        s.blocks * ts.blocksize, s.blocks, s.extents,
  3030.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize, s.minexts, 
  3031.        s.maxexts, s.extpct,
  3032.        decode(s.lists, 0, 1, s.lists), decode(s.groups, 0, 1, s.groups)
  3033. from sys.ts$ ts, sys.seg$ s
  3034. where s.ts# = ts.ts#
  3035.   and s.user# = userenv('SCHEMAID')
  3036.   and s.type not in (1, 5, 6)
  3037. /
  3038. comment on table USER_SEGMENTS is
  3039. 'Storage allocated for all database segments'
  3040. /
  3041. comment on column USER_SEGMENTS.SEGMENT_NAME is
  3042. 'Name, if any, of the segment'
  3043. /
  3044. comment on column USER_SEGMENTS.SEGMENT_TYPE is
  3045. 'Type of segment:  "TABLE", "CLUSTER", "INDEX", "ROLLBACK",
  3046. "DEFERRED ROLLBACK", "TEMPORARY", or "CACHE"'
  3047. /
  3048. comment on column USER_SEGMENTS.TABLESPACE_NAME is
  3049. 'Name of the tablespace containing the segment'
  3050. /
  3051. comment on column USER_SEGMENTS.BYTES is
  3052. 'Size, in bytes, of the segment'
  3053. /
  3054. comment on column USER_SEGMENTS.BLOCKS is
  3055. 'Size, in Oracle blocks, of the segment'
  3056. /
  3057. comment on column USER_SEGMENTS.EXTENTS is
  3058. 'Number of extents allocated to the segment'
  3059. /
  3060. comment on column USER_SEGMENTS.INITIAL_EXTENT is
  3061. 'Size, in bytes, of the initial extent of the segment'
  3062. /
  3063. comment on column USER_SEGMENTS.NEXT_EXTENT is
  3064. 'Size, in bytes, of the next extent to be allocated to the segment' 
  3065. /
  3066. comment on column USER_SEGMENTS.MIN_EXTENTS is
  3067. 'Minimum number of extents allowed in the segment'
  3068. /
  3069. comment on column USER_SEGMENTS.MAX_EXTENTS is
  3070. 'Maximum number of extents allowed in the segment'
  3071. /
  3072. comment on column USER_SEGMENTS.PCT_INCREASE is
  3073. 'Percent by which to increase the size of the next extent to be allocated'
  3074. /
  3075. comment on column USER_SEGMENTS.FREELISTS is
  3076. 'Number of process freelists allocated to this segment'
  3077. /
  3078. comment on column USER_SEGMENTS.FREELIST_GROUPS is
  3079. 'Number of freelist groups allocated to this segment'
  3080. /
  3081. drop public synonym USER_SEGMENTS
  3082. /
  3083. create public synonym USER_SEGMENTS for USER_SEGMENTS
  3084. /
  3085. grant select on USER_SEGMENTS to PUBLIC with grant option
  3086. /
  3087. create or replace view DBA_SEGMENTS
  3088.     (OWNER, SEGMENT_NAME,
  3089.      SEGMENT_TYPE,
  3090.      TABLESPACE_NAME,
  3091.      HEADER_FILE, HEADER_BLOCK,
  3092.      BYTES, BLOCKS, EXTENTS, 
  3093.      INITIAL_EXTENT, NEXT_EXTENT,
  3094.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE, FREELISTS, FREELIST_GROUPS)
  3095. as
  3096. select u.name, o.name,
  3097.        so.object_type,
  3098.        ts.name,
  3099.        s.file#, s.block#,
  3100.        s.blocks * ts.blocksize, s.blocks, s.extents, 
  3101.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize, s.minexts, 
  3102.        s.maxexts, s.extpct,
  3103.        decode(s.lists, 0, 1, s.lists), decode(s.groups, 0, 1, s.groups)
  3104. from sys.user$ u, sys.obj$ o, sys.ts$ ts, sys.sys_objects so, sys.seg$ s
  3105. where s.file# = so.header_file
  3106.   and s.block# = so.header_block
  3107.   and s.ts# = ts.ts#
  3108.   and o.obj# = so.object_id
  3109.   and o.owner# = u.user#
  3110.   and s.type = so.segment_type_id
  3111.   and o.type = so.object_type_id
  3112. union all
  3113. select u.name, un.name,
  3114.        'ROLLBACK', ts.name, s.file#, s.block#,
  3115.        s.blocks * ts.blocksize, s.blocks, s.extents,
  3116.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize, s.minexts, 
  3117.        s.maxexts, s.extpct,
  3118.        decode(s.lists, 0, 1, s.lists), decode(s.groups, 0, 1, s.groups)
  3119. from sys.user$ u, sys.ts$ ts, sys.undo$ un, sys.seg$ s
  3120. where s.file# = un.file#
  3121.   and s.block# = un.block#
  3122.   and s.ts# = ts.ts#
  3123.   and s.user# = u.user#
  3124.   and s.type = 1
  3125.   and un.status$ != 1
  3126. union all
  3127. select u.name, to_char(s.file#) || '.' || to_char(s.block#),
  3128.        decode(s.type, 2, 'DEFERRED ROLLBACK', 3, 'TEMPORARY',
  3129.                       4, 'CACHE', 'UNDEFINED'),
  3130.        ts.name,
  3131.        s.file#, s.block#,
  3132.        s.blocks * ts.blocksize, s.blocks, s.extents,
  3133.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize, s.minexts, 
  3134.        s.maxexts, s.extpct,
  3135.        decode(s.lists, 0, 1, s.lists), decode(s.groups, 0, 1, s.groups)
  3136. from sys.user$ u, sys.ts$ ts, sys.seg$ s
  3137. where s.ts# = ts.ts#
  3138.   and s.user# = u.user#
  3139.   and s.type not in (1, 5, 6)
  3140. /
  3141. comment on table DBA_SEGMENTS is
  3142. 'Storage allocated for all database segments'
  3143. /
  3144. comment on column DBA_SEGMENTS.OWNER is
  3145. 'Username of the segment owner'
  3146. /
  3147. comment on column DBA_SEGMENTS.SEGMENT_NAME is
  3148. 'Name, if any, of the segment'
  3149. /
  3150. comment on column DBA_SEGMENTS.SEGMENT_TYPE is
  3151. 'Type of segment:  "TABLE", "CLUSTER", "INDEX", "ROLLBACK",
  3152. "DEFERRED ROLLBACK", "TEMPORARY", or "CACHE"'
  3153. /
  3154. comment on column DBA_SEGMENTS.TABLESPACE_NAME is
  3155. 'Name of the tablespace containing the segment'
  3156. /
  3157. comment on column DBA_SEGMENTS.HEADER_FILE is
  3158. 'ID of the file containing the segment header'
  3159. /
  3160. comment on column DBA_SEGMENTS.HEADER_BLOCK is
  3161. 'ID of the block containing the segment header'
  3162. /
  3163. comment on column DBA_SEGMENTS.BYTES is
  3164. 'Size, in bytes, of the segment'
  3165. /
  3166. comment on column DBA_SEGMENTS.BLOCKS is
  3167. 'Size, in Oracle blocks, of the segment'
  3168. /
  3169. comment on column DBA_SEGMENTS.EXTENTS is
  3170. 'Number of extents allocated to the segment'
  3171. /
  3172. comment on column DBA_SEGMENTS.INITIAL_EXTENT is
  3173. 'Size, in bytes, of the initial extent of the segment'
  3174. /
  3175. comment on column DBA_SEGMENTS.NEXT_EXTENT is
  3176. 'Size, in bytes, of the next extent to be allocated to the segment' 
  3177. /
  3178. comment on column DBA_SEGMENTS.MIN_EXTENTS is
  3179. 'Minimum number of extents allowed in the segment'
  3180. /
  3181. comment on column DBA_SEGMENTS.MAX_EXTENTS is
  3182. 'Maximum number of extents allowed in the segment'
  3183. /
  3184. comment on column DBA_SEGMENTS.PCT_INCREASE is
  3185. 'Percent by which to increase the size of the next extent to be allocated'
  3186. /
  3187. comment on column DBA_SEGMENTS.FREELISTS is
  3188. 'Number of process freelists allocated in this segment'
  3189. /
  3190. comment on column DBA_SEGMENTS.FREELIST_GROUPS is
  3191. 'Number of freelist groups allocated in this segment'
  3192. /
  3193. remark
  3194. remark  FAMILY "EXTENTS"
  3195. remark  Extents associated with their segments.
  3196. remark
  3197. create or replace view USER_EXTENTS
  3198.     (SEGMENT_NAME, SEGMENT_TYPE, TABLESPACE_NAME,
  3199.      EXTENT_ID, BYTES, BLOCKS)
  3200. as
  3201. select ds.segment_name, ds.segment_type, ds.tablespace_name,
  3202.        e.ext#, e.length * ts.blocksize, e.length
  3203. from sys.uet$ e, sys.dba_segments ds, sys.ts$ ts
  3204. where e.segfile# = ds.header_file
  3205.   and e.segblock# = ds.header_block
  3206.   and ds.tablespace_name = ts.name
  3207.   and ds.owner = user
  3208. /
  3209. comment on table USER_EXTENTS is
  3210. 'Extents comprising segments owned by the user'
  3211. /
  3212. comment on column USER_EXTENTS.SEGMENT_NAME is
  3213. 'Name of the segment associated with the extent'
  3214. /
  3215. comment on column USER_EXTENTS.TABLESPACE_NAME is
  3216. 'Name of the tablespace containing the extent'
  3217. /
  3218. comment on column USER_EXTENTS.SEGMENT_TYPE is
  3219. 'Type of the segment'
  3220. /
  3221. comment on column USER_EXTENTS.EXTENT_ID is
  3222. 'Extent number in the segment'
  3223. /
  3224. comment on column USER_EXTENTS.BYTES is
  3225. 'Size of the extent in bytes'
  3226. /
  3227. comment on column USER_EXTENTS.BLOCKS is
  3228. 'Size of the extent in ORACLE blocks'
  3229. /
  3230. drop public synonym USER_EXTENTS
  3231. /
  3232. create public synonym USER_EXTENTS for USER_EXTENTS
  3233. /
  3234. grant select on USER_EXTENTS to PUBLIC with grant option
  3235. /
  3236. create or replace view DBA_EXTENTS
  3237.     (OWNER, SEGMENT_NAME, SEGMENT_TYPE, TABLESPACE_NAME,
  3238.      EXTENT_ID, FILE_ID, BLOCK_ID,
  3239.      BYTES, BLOCKS)
  3240. as
  3241. select ds.owner, ds.segment_name, ds.segment_type, ds.tablespace_name,
  3242.        e.ext#, e.file#, e.block#, e.length * ts.blocksize, e.length
  3243. from sys.uet$ e, sys.dba_segments ds, sys.ts$ ts
  3244. where e.segfile# = ds.header_file
  3245.   and e.segblock# = ds.header_block
  3246.   and ds.tablespace_name = ts.name
  3247. /
  3248. comment on table DBA_EXTENTS is
  3249. 'Extents comprising all segments in the database'
  3250. /
  3251. comment on column DBA_EXTENTS.OWNER is
  3252. 'Owner of the segment associated with the extent'
  3253. /
  3254. comment on column DBA_EXTENTS.SEGMENT_NAME is
  3255. 'Name of the segment associated with the extent'
  3256. /
  3257. comment on column DBA_EXTENTS.TABLESPACE_NAME is
  3258. 'Name of the tablespace containing the extent'
  3259. /
  3260. comment on column DBA_EXTENTS.SEGMENT_TYPE is
  3261. 'Type of the segment'
  3262. /
  3263. comment on column DBA_EXTENTS.FILE_ID is
  3264. 'Name of the file containing the extent'
  3265. /
  3266. comment on column DBA_EXTENTS.BLOCK_ID is
  3267. 'Starting block number of the extent'
  3268. /
  3269. comment on column DBA_EXTENTS.EXTENT_ID is
  3270. 'Extent number in the segment'
  3271. /
  3272. comment on column DBA_EXTENTS.BYTES is
  3273. 'Size of the extent in bytes'
  3274. /
  3275. comment on column DBA_EXTENTS.BLOCKS is
  3276. 'Size of the extent in ORACLE blocks'
  3277. /
  3278. remark
  3279. remark  FAMILY "SEQUENCES"
  3280. remark  CREATE SEQUENCE information.
  3281. remark
  3282. create or replace view USER_SEQUENCES
  3283.   (SEQUENCE_NAME, MIN_VALUE, MAX_VALUE, INCREMENT_BY,
  3284.                   CYCLE_FLAG, ORDER_FLAG, CACHE_SIZE, LAST_NUMBER)
  3285. as select o.name,
  3286.       s.minvalue, s.maxvalue, s.increment$,
  3287.       decode (s.cycle, 0, 'N', 1, 'Y'),
  3288.       decode (s.order$, 0, 'N', 1, 'Y'),
  3289.       s.cache, s.highwater
  3290. from sys.seq$ s, sys.obj$ o
  3291. where o.owner# = userenv('SCHEMAID')
  3292.   and o.obj# = s.obj#
  3293. /
  3294. comment on table USER_SEQUENCES is
  3295. 'Description of the user''s own SEQUENCEs'
  3296. /
  3297. comment on column USER_SEQUENCES.SEQUENCE_NAME is
  3298. 'SEQUENCE name'
  3299. /
  3300. comment on column USER_SEQUENCES.INCREMENT_BY is
  3301. 'Value by which sequence is incremented'
  3302. /
  3303. comment on column USER_SEQUENCES.MIN_VALUE is
  3304. 'Minimum value of the sequence'
  3305. /
  3306. comment on column USER_SEQUENCES.MAX_VALUE is
  3307. 'Maximum value of the sequence'
  3308. /
  3309. comment on column USER_SEQUENCES.CYCLE_FLAG is
  3310. 'Does sequence wrap around on reaching limit?'
  3311. /
  3312. comment on column USER_SEQUENCES.ORDER_FLAG is
  3313. 'Are sequence numbers generated in order?'
  3314. /
  3315. comment on column USER_SEQUENCES.CACHE_SIZE is
  3316. 'Number of sequence numbers to cache'
  3317. /
  3318. comment on column USER_SEQUENCES.LAST_NUMBER is
  3319. 'Last sequence number written to disk'
  3320. /
  3321. drop public synonym USER_SEQUENCES
  3322. /
  3323. create public synonym USER_SEQUENCES for USER_SEQUENCES
  3324. /
  3325. drop public synonym SEQ
  3326. /
  3327. create public synonym SEQ for USER_SEQUENCES
  3328. /
  3329. grant select on USER_SEQUENCES to PUBLIC with grant option
  3330. /
  3331. create or replace view ALL_SEQUENCES
  3332.   (SEQUENCE_OWNER, SEQUENCE_NAME, 
  3333.                   MIN_VALUE, MAX_VALUE, INCREMENT_BY,
  3334.                   CYCLE_FLAG, ORDER_FLAG, CACHE_SIZE, LAST_NUMBER)
  3335. as select u.name, o.name,
  3336.       s.minvalue, s.maxvalue, s.increment$, 
  3337.       decode (s.cycle, 0, 'N', 1, 'Y'),
  3338.       decode (s.order$, 0, 'N', 1, 'Y'),
  3339.       s.cache, s.highwater
  3340. from sys.seq$ s, sys.obj$ o, sys.user$ u
  3341. where u.user# = o.owner#
  3342.   and o.obj# = s.obj#
  3343.   and (o.owner# = userenv('SCHEMAID')
  3344.        or o.obj# in
  3345.             (select oa.obj#
  3346.              from sys.objauth$ oa
  3347.              where grantee# in ( select kzsrorol
  3348.                                  from x$kzsro
  3349.                                )
  3350.             )
  3351.         or
  3352.      exists (select null from v$enabledprivs
  3353.              where priv_number = -109 /* SELECT ANY SEQUENCE */
  3354.                  )
  3355.       )
  3356. /
  3357. comment on table ALL_SEQUENCES is
  3358. 'Description of SEQUENCEs accessible to the user'
  3359. /
  3360. comment on column ALL_SEQUENCES.SEQUENCE_OWNER is
  3361. 'Name of the owner of the sequence'
  3362. /
  3363. comment on column ALL_SEQUENCES.SEQUENCE_NAME is
  3364. 'SEQUENCE name'
  3365. /
  3366. comment on column ALL_SEQUENCES.INCREMENT_BY is
  3367. 'Value by which sequence is incremented'
  3368. /
  3369. comment on column ALL_SEQUENCES.MIN_VALUE is
  3370. 'Minimum value of the sequence'
  3371. /
  3372. comment on column ALL_SEQUENCES.MAX_VALUE is
  3373. 'Maximum value of the sequence'
  3374. /
  3375. comment on column ALL_SEQUENCES.CYCLE_FLAG is
  3376. 'Does sequence wrap around on reaching limit?'
  3377. /
  3378. comment on column ALL_SEQUENCES.ORDER_FLAG is
  3379. 'Are sequence numbers generated in order?'
  3380. /
  3381. comment on column ALL_SEQUENCES.CACHE_SIZE is
  3382. 'Number of sequence numbers to cache'
  3383. /
  3384. comment on column ALL_SEQUENCES.LAST_NUMBER is
  3385. 'Last sequence number written to disk'
  3386. /
  3387. drop public synonym ALL_SEQUENCES
  3388. /
  3389. create public synonym ALL_SEQUENCES for ALL_SEQUENCES
  3390. /
  3391. grant select on ALL_SEQUENCES to PUBLIC with grant option
  3392. /
  3393. create or replace view DBA_SEQUENCES
  3394.   (SEQUENCE_OWNER, SEQUENCE_NAME, 
  3395.                   MIN_VALUE, MAX_VALUE, INCREMENT_BY,
  3396.                   CYCLE_FLAG, ORDER_FLAG, CACHE_SIZE, LAST_NUMBER)
  3397. as select u.name, o.name,
  3398.       s.minvalue, s.maxvalue, s.increment$, 
  3399.       decode (s.cycle, 0, 'N', 1, 'Y'),
  3400.       decode (s.order$, 0, 'N', 1, 'Y'),
  3401.       s.cache, s.highwater
  3402. from sys.seq$ s, sys.obj$ o, sys.user$ u
  3403. where u.user# = o.owner#
  3404.   and o.obj# = s.obj#
  3405. /
  3406. comment on table DBA_SEQUENCES is
  3407. 'Description of all SEQUENCEs in the database'
  3408. /
  3409. comment on column DBA_SEQUENCES.SEQUENCE_OWNER is
  3410. 'Name of the owner of the sequence'
  3411. /
  3412. comment on column DBA_SEQUENCES.SEQUENCE_NAME is
  3413. 'SEQUENCE name'
  3414. /
  3415. comment on column DBA_SEQUENCES.INCREMENT_BY is
  3416. 'Value by which sequence is incremented'
  3417. /
  3418. comment on column DBA_SEQUENCES.MIN_VALUE is
  3419. 'Minimum value of the sequence'
  3420. /
  3421. comment on column DBA_SEQUENCES.MAX_VALUE is
  3422. 'Maximum value of the sequence'
  3423. /
  3424. comment on column DBA_SEQUENCES.CYCLE_FLAG is
  3425. 'Does sequence wrap around on reaching limit?'
  3426. /
  3427. comment on column DBA_SEQUENCES.ORDER_FLAG is
  3428. 'Are sequence numbers generated in order?'
  3429. /
  3430. comment on column DBA_SEQUENCES.CACHE_SIZE is
  3431. 'Number of sequence numbers to cache'
  3432. /
  3433. comment on column DBA_SEQUENCES.LAST_NUMBER is
  3434. 'Last sequence number written to disk'
  3435. /
  3436. remark
  3437. remark  FAMILY "SYNONYMS"
  3438. remark  CREATE SYNONYM information.
  3439. remark
  3440. create or replace view USER_SYNONYMS
  3441.     (SYNONYM_NAME, TABLE_OWNER, TABLE_NAME, DB_LINK)
  3442. as select o.name, s.owner, s.name, s.node
  3443. from sys.syn$ s, sys.obj$ o
  3444. where o.obj# = s.obj#
  3445.   and o.type = 5
  3446.   and o.owner# = userenv('SCHEMAID')
  3447. /
  3448. comment on table USER_SYNONYMS is
  3449. 'The user''s private synonyms'
  3450. /
  3451. comment on column USER_SYNONYMS.SYNONYM_NAME is
  3452. 'Name of the synonym'
  3453. /
  3454. comment on column USER_SYNONYMS.TABLE_OWNER is
  3455. 'Owner of the object referenced by the synonym'
  3456. /
  3457. comment on column USER_SYNONYMS.TABLE_NAME is
  3458. 'Name of the object referenced by the synonym'
  3459. /
  3460. comment on column USER_SYNONYMS.DB_LINK is
  3461. 'Database link referenced in a remote synonym'
  3462. /
  3463. drop public synonym SYN
  3464. /
  3465. create public synonym SYN for USER_SYNONYMS
  3466. /
  3467. drop public synonym USER_SYNONYMS
  3468. /
  3469. create public synonym USER_SYNONYMS for USER_SYNONYMS
  3470. /
  3471. grant select on USER_SYNONYMS to PUBLIC with grant option
  3472. /
  3473. remark
  3474. remark  This view shows all synonyms owned by the user (private synonyms),
  3475. remark  plus all public synonyms.
  3476. remark
  3477. create or replace view ALL_SYNONYMS
  3478.     (OWNER, SYNONYM_NAME, TABLE_OWNER, TABLE_NAME, DB_LINK)
  3479. as
  3480. select u.name, o.name, s.owner, s.name, s.node
  3481. from sys.user$ u, sys.syn$ s, sys.obj$ o
  3482. where o.obj# = s.obj#
  3483.   and o.type = 5
  3484.   and o.owner# = u.user#
  3485.   and (
  3486.        o.owner# in (USERENV('SCHEMAID'), 1 /* PUBLIC */)  /* user's private, any public */
  3487.        or /* user has any privs on base object */
  3488.     exists
  3489.         (select null from sys.objauth$ ba, sys.obj$ bo, sys.user$ bu
  3490.          where bu.name = s.owner
  3491.            and bo.name = s.name
  3492.            and bu.user# = bo.owner#
  3493.            and ba.obj# = bo.obj#
  3494.            and ba.grantee# in (select kzsrorol from x$kzsro))
  3495.         or /* user has system privileges */
  3496.      exists (select null from v$enabledprivs
  3497.              where priv_number in (-45 /* LOCK ANY TABLE */,
  3498.                        -47 /* SELECT ANY TABLE */,
  3499.                        -48 /* INSERT ANY TABLE */,
  3500.                        -49 /* UPDATE ANY TABLE */,
  3501.                        -50 /* DELETE ANY TABLE */)
  3502.                  )
  3503.        )
  3504. /
  3505. comment on table ALL_SYNONYMS is
  3506. 'All synonyms accessible to the user'
  3507. /
  3508. comment on column ALL_SYNONYMS.OWNER is
  3509. 'Owner of the synonym'
  3510. /
  3511. comment on column ALL_SYNONYMS.SYNONYM_NAME is
  3512. 'Name of the synonym'
  3513. /
  3514. comment on column ALL_SYNONYMS.TABLE_OWNER is
  3515. 'Owner of the object referenced by the synonym'
  3516. /
  3517. comment on column ALL_SYNONYMS.TABLE_NAME is
  3518. 'Name of the object referenced by the synonym'
  3519. /
  3520. comment on column ALL_SYNONYMS.DB_LINK is
  3521. 'Name of the database link referenced in a remote synonym'
  3522. /
  3523. drop public synonym ALL_SYNONYMS
  3524. /
  3525. create public synonym ALL_SYNONYMS for ALL_SYNONYMS
  3526. /
  3527. grant select on ALL_SYNONYMS to PUBLIC with grant option
  3528. /
  3529. create or replace view DBA_SYNONYMS
  3530.     (OWNER, SYNONYM_NAME, TABLE_OWNER, TABLE_NAME, DB_LINK)
  3531. as select u.name, o.name, s.owner, s.name, s.node
  3532. from sys.user$ u, sys.syn$ s, sys.obj$ o
  3533. where o.obj# = s.obj#
  3534.   and o.type = 5
  3535.   and o.owner# = u.user#
  3536. /
  3537. comment on table DBA_SYNONYMS is
  3538. 'All synonyms in the database'
  3539. /
  3540. comment on column DBA_SYNONYMS.OWNER is
  3541. 'Username of the owner of the synonym'
  3542. /
  3543. comment on column DBA_SYNONYMS.SYNONYM_NAME is
  3544. 'Name of the synonym'
  3545. /
  3546. comment on column DBA_SYNONYMS.TABLE_OWNER is
  3547. 'Owner of the object referenced by the synonym'
  3548. /
  3549. comment on column DBA_SYNONYMS.TABLE_NAME is
  3550. 'Name of the object referenced by the synonym'
  3551. /
  3552. comment on column DBA_SYNONYMS.DB_LINK is
  3553. 'Name of the database link referenced in a remote synonym'
  3554. /
  3555. remark
  3556. remark  FAMILY "TABLES"
  3557. remark  CREATE TABLE parameters.
  3558. remark
  3559. create or replace view USER_TABLES
  3560.     (TABLE_NAME, TABLESPACE_NAME, CLUSTER_NAME,
  3561.      PCT_FREE, PCT_USED,
  3562.      INI_TRANS, MAX_TRANS,
  3563.      INITIAL_EXTENT, NEXT_EXTENT,
  3564.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE,
  3565.      BACKED_UP, NUM_ROWS, BLOCKS, EMPTY_BLOCKS,
  3566.      AVG_SPACE, CHAIN_CNT, AVG_ROW_LEN,
  3567.      DEGREE, INSTANCES, CACHE)
  3568. as
  3569. select o.name, ts.name, co.name,
  3570.        t.pctfree$, t.pctused$,
  3571.        t.initrans, t.maxtrans,
  3572.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize,
  3573.        s.minexts, s.maxexts, s.extpct,
  3574.        decode(t.modified, 0, 'Y', 1, 'N', '?'),
  3575.        t.rowcnt, t.blkcnt, t.empcnt, t.avgspc, t.chncnt, t.avgrln,
  3576.        lpad(decode(t.spare1, 0, '1', 1, 'DEFAULT', to_char(t.spare1)), 10),
  3577.        lpad(decode(mod(t.spare2, 65536), 0, '1', 1, 'DEFAULT',
  3578.        to_char(mod(t.spare2, 65536))), 10),
  3579.        lpad(decode(floor(t.spare2 / 65536), 0, 'N', 1, 'Y', '?'), 5)
  3580. from sys.ts$ ts, sys.seg$ s, sys.obj$ co, sys.tab$ t, sys.obj$ o
  3581. where o.owner# = userenv('SCHEMAID')
  3582.   and o.obj# = t.obj#
  3583.   and t.clu# = co.obj# (+)
  3584.   and t.ts# = ts.ts#
  3585.   and t.file# = s.file# (+)
  3586.   and t.block# = s.block# (+)
  3587. /
  3588. comment on table USER_TABLES is
  3589. 'Description of the user''s own tables'
  3590. /
  3591. comment on column USER_TABLES.TABLE_NAME is
  3592. 'Name of the table'
  3593. /
  3594. comment on column USER_TABLES.TABLESPACE_NAME is
  3595. 'Name of the tablespace containing the table'
  3596. /
  3597. comment on column USER_TABLES.CLUSTER_NAME is
  3598. 'Name of the cluster, if any, to which the table belongs'
  3599. /
  3600. comment on column USER_TABLES.PCT_FREE is
  3601. 'Minimum percentage of free space in a block'
  3602. /
  3603. comment on column USER_TABLES.PCT_USED is
  3604. 'Minimum percentage of used space in a block'
  3605. /
  3606. comment on column USER_TABLES.INI_TRANS is
  3607. 'Initial number of transactions'
  3608. /
  3609. comment on column USER_TABLES.MAX_TRANS is
  3610. 'Maximum number of transactions'
  3611. /
  3612. comment on column USER_TABLES.INITIAL_EXTENT is
  3613. 'Size of the initial extent in bytes'
  3614. /
  3615. comment on column USER_TABLES.NEXT_EXTENT is
  3616. 'Size of secondary extents in bytes'
  3617. /
  3618. comment on column USER_TABLES.MIN_EXTENTS is
  3619. 'Minimum number of extents allowed in the segment'
  3620. /
  3621. comment on column USER_TABLES.MAX_EXTENTS is
  3622. 'Maximum number of extents allowed in the segment'
  3623. /
  3624. comment on column USER_TABLES.PCT_INCREASE is
  3625. 'Percentage increase in extent size'
  3626. /
  3627. comment on column USER_TABLES.BACKED_UP is
  3628. 'Has table been backed up since last modification?'
  3629. /
  3630. comment on column USER_TABLES.NUM_ROWS is
  3631. 'The number of rows in the table'
  3632. /
  3633. comment on column USER_TABLES.BLOCKS is
  3634. 'The number of used blocks in the table'
  3635. /
  3636. comment on column USER_TABLES.EMPTY_BLOCKS is
  3637. 'The number of empty (never used) blocks in the table'
  3638. /
  3639. comment on column USER_TABLES.AVG_SPACE is
  3640. 'The average available free space in the table'
  3641. /
  3642. comment on column USER_TABLES.CHAIN_CNT is
  3643. 'The number of chained rows in the table'
  3644. /
  3645. comment on column USER_TABLES.AVG_ROW_LEN is
  3646. 'The average row length, including row overhead'
  3647. /
  3648. comment on column USER_TABLES.DEGREE is
  3649. 'The number of threads per instance for scanning the table'
  3650. /
  3651. comment on column USER_TABLES.INSTANCES is
  3652. 'The number of instances across which the table is to be scanned'
  3653. /
  3654. comment on column USER_TABLES.CACHE is
  3655. 'Whether the table is to be cached in the buffer cache'
  3656. /
  3657. drop public synonym USER_TABLES
  3658. /
  3659. create public synonym USER_TABLES for USER_TABLES
  3660. /
  3661. drop public synonym TABS
  3662. /
  3663. create public synonym TABS for USER_TABLES
  3664. /
  3665. grant select on USER_TABLES to PUBLIC with grant option
  3666. /
  3667. create or replace view ALL_TABLES
  3668.     (OWNER, TABLE_NAME, TABLESPACE_NAME, CLUSTER_NAME,
  3669.      PCT_FREE, PCT_USED,
  3670.      INI_TRANS, MAX_TRANS,
  3671.      INITIAL_EXTENT, NEXT_EXTENT,
  3672.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE,
  3673.      BACKED_UP, NUM_ROWS, BLOCKS, EMPTY_BLOCKS,
  3674.      AVG_SPACE, CHAIN_CNT, AVG_ROW_LEN,
  3675.      DEGREE, INSTANCES, CACHE)
  3676. as
  3677. select u.name, o.name, ts.name, co.name,
  3678.        t.pctfree$, t.pctused$,
  3679.        t.initrans, t.maxtrans,
  3680.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize,
  3681.        s.minexts, s.maxexts, s.extpct,
  3682.        decode(t.modified, 0, 'Y', 1, 'N', '?'),
  3683.        t.rowcnt, t.blkcnt, t.empcnt, t.avgspc, t.chncnt, t.avgrln,
  3684.        lpad(decode(t.spare1, 0, '1', 1, 'DEFAULT', to_char(t.spare1)), 10),
  3685.        lpad(decode(mod(t.spare2, 65536), 0, '1', 1, 'DEFAULT',
  3686.        to_char(mod(t.spare2, 65536))), 10),
  3687.        lpad(decode(floor(t.spare2 / 65536), 0, 'N', 1, 'Y', '?'), 5)
  3688. from sys.user$ u, sys.ts$ ts, sys.seg$ s, sys.obj$ co, sys.tab$ t, sys.obj$ o
  3689. where o.owner# = u.user#
  3690.   and o.obj# = t.obj#
  3691.   and t.clu# = co.obj# (+)
  3692.   and t.ts# = ts.ts#
  3693.   and t.file# = s.file# (+)
  3694.   and t.block# = s.block# (+)
  3695.   and (o.owner# = userenv('SCHEMAID')
  3696.        or o.obj# in
  3697.             (select oa.obj#
  3698.              from sys.objauth$ oa
  3699.              where grantee# in ( select kzsrorol
  3700.                                  from x$kzsro
  3701.                                ) 
  3702.             )
  3703.        or /* user has system privileges */
  3704.      exists (select null from v$enabledprivs
  3705.              where priv_number in (-45 /* LOCK ANY TABLE */,
  3706.                        -47 /* SELECT ANY TABLE */,
  3707.                        -48 /* INSERT ANY TABLE */,
  3708.                        -49 /* UPDATE ANY TABLE */,
  3709.                        -50 /* DELETE ANY TABLE */)
  3710.                  )
  3711.       )
  3712. /
  3713. comment on table ALL_TABLES is
  3714. 'Description of tables accessible to the user'
  3715. /
  3716. comment on column ALL_TABLES.OWNER is
  3717. 'Owner of the table'
  3718. /
  3719. comment on column ALL_TABLES.TABLE_NAME is
  3720. 'Name of the table'
  3721. /
  3722. comment on column ALL_TABLES.TABLESPACE_NAME is
  3723. 'Name of the tablespace containing the table'
  3724. /
  3725. comment on column ALL_TABLES.CLUSTER_NAME is
  3726. 'Name of the cluster, if any, to which the table belongs'
  3727. /
  3728. comment on column ALL_TABLES.PCT_FREE is
  3729. 'Minimum percentage of free space in a block'
  3730. /
  3731. comment on column ALL_TABLES.PCT_USED is
  3732. 'Minimum percentage of used space in a block'
  3733. /
  3734. comment on column ALL_TABLES.INI_TRANS is
  3735. 'Initial number of transactions'
  3736. /
  3737. comment on column ALL_TABLES.MAX_TRANS is
  3738. 'Maximum number of transactions'
  3739. /
  3740. comment on column ALL_TABLES.INITIAL_EXTENT is
  3741. 'Size of the initial extent in bytes'
  3742. /
  3743. comment on column ALL_TABLES.NEXT_EXTENT is
  3744. 'Size of secondary extents in bytes'
  3745. /
  3746. comment on column ALL_TABLES.MIN_EXTENTS is
  3747. 'Minimum number of extents allowed in the segment'
  3748. /
  3749. comment on column ALL_TABLES.MAX_EXTENTS is
  3750. 'Maximum number of extents allowed in the segment'
  3751. /
  3752. comment on column ALL_TABLES.PCT_INCREASE is
  3753. 'Percentage increase in extent size'
  3754. /
  3755. comment on column ALL_TABLES.BACKED_UP is
  3756. 'Has table been backed up since last modification?'
  3757. /
  3758. comment on column ALL_TABLES.NUM_ROWS is
  3759. 'The number of rows in the table'
  3760. /
  3761. comment on column ALL_TABLES.BLOCKS is
  3762. 'The number of used blocks in the table'
  3763. /
  3764. comment on column ALL_TABLES.EMPTY_BLOCKS is
  3765. 'The number of empty (never used) blocks in the table'
  3766. /
  3767. comment on column ALL_TABLES.AVG_SPACE is
  3768. 'The average available free space in the table'
  3769. /
  3770. comment on column ALL_TABLES.CHAIN_CNT is
  3771. 'The number of chained rows in the table'
  3772. /
  3773. comment on column ALL_TABLES.AVG_ROW_LEN is
  3774. 'The average row length, including row overhead'
  3775. /
  3776. comment on column ALL_TABLES.DEGREE is
  3777. 'The number of threads per instance for scanning the table'
  3778. /
  3779. comment on column ALL_TABLES.INSTANCES is
  3780. 'The number of instances across which the table is to be scanned'
  3781. /
  3782. comment on column ALL_TABLES.CACHE is
  3783. 'Whether the table is to be cached in the buffer cache'
  3784. /
  3785. drop public synonym ALL_TABLES
  3786. /
  3787. create public synonym ALL_TABLES for ALL_TABLES
  3788. /
  3789. grant select on ALL_TABLES to PUBLIC with grant option
  3790. /
  3791. create or replace view DBA_TABLES
  3792.     (OWNER, TABLE_NAME, TABLESPACE_NAME, CLUSTER_NAME,
  3793.      PCT_FREE, PCT_USED,
  3794.      INI_TRANS, MAX_TRANS,
  3795.      INITIAL_EXTENT, NEXT_EXTENT,
  3796.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE,
  3797.      BACKED_UP, NUM_ROWS, BLOCKS, EMPTY_BLOCKS,
  3798.      AVG_SPACE, CHAIN_CNT, AVG_ROW_LEN,
  3799.      DEGREE, INSTANCES, CACHE)
  3800. as
  3801. select u.name, o.name, ts.name, co.name,
  3802.        t.pctfree$, t.pctused$,
  3803.        t.initrans, t.maxtrans,
  3804.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize,
  3805.        s.minexts, s.maxexts, s.extpct,
  3806.        decode(t.modified, 0, 'Y', 1, 'N', '?'),
  3807.        t.rowcnt, t.blkcnt, t.empcnt, t.avgspc, t.chncnt, t.avgrln,
  3808.        lpad(decode(t.spare1, 0, '1', 1, 'DEFAULT', to_char(t.spare1)), 10),
  3809.        lpad(decode(mod(t.spare2, 65536), 0, '1', 1, 'DEFAULT',
  3810.        to_char(mod(t.spare2, 65536))), 10),
  3811.        lpad(decode(floor(t.spare2 / 65536), 0, 'N', 1, 'Y', '?'), 5)
  3812. from sys.user$ u, sys.ts$ ts, sys.seg$ s, sys.obj$ co, sys.tab$ t, sys.obj$ o
  3813. where o.owner# = u.user#
  3814.   and o.obj# = t.obj#
  3815.   and t.clu# = co.obj# (+)
  3816.   and t.ts# = ts.ts#
  3817.   and t.file# = s.file# (+)
  3818.   and t.block# = s.block# (+)
  3819. /
  3820. comment on table DBA_TABLES is
  3821. 'Description of all tables in the database'
  3822. /
  3823. comment on column DBA_TABLES.OWNER is
  3824. 'Owner of the table'
  3825. /
  3826. comment on column DBA_TABLES.TABLE_NAME is
  3827. 'Name of the table'
  3828. /
  3829. comment on column DBA_TABLES.TABLESPACE_NAME is
  3830. 'Name of the tablespace containing the table'
  3831. /
  3832. comment on column DBA_TABLES.CLUSTER_NAME is
  3833. 'Name of the cluster, if any, to which the table belongs'
  3834. /
  3835. comment on column DBA_TABLES.PCT_FREE is
  3836. 'Minimum percentage of free space in a block'
  3837. /
  3838. comment on column DBA_TABLES.PCT_USED is
  3839. 'Minimum percentage of used space in a block'
  3840. /
  3841. comment on column DBA_TABLES.INI_TRANS is
  3842. 'Initial number of transactions'
  3843. /
  3844. comment on column DBA_TABLES.MAX_TRANS is
  3845. 'Maximum number of transactions'
  3846. /
  3847. comment on column DBA_TABLES.INITIAL_EXTENT is
  3848. 'Size of the initial extent in bytes'
  3849. /
  3850. comment on column DBA_TABLES.NEXT_EXTENT is
  3851. 'Size of secondary extents in bytes'
  3852. /
  3853. comment on column DBA_TABLES.MIN_EXTENTS is
  3854. 'Minimum number of extents allowed in the segment'
  3855. /
  3856. comment on column DBA_TABLES.MAX_EXTENTS is
  3857. 'Maximum number of extents allowed in the segment'
  3858. /
  3859. comment on column DBA_TABLES.PCT_INCREASE is
  3860. 'Percentage increase in extent size'
  3861. /
  3862. comment on column DBA_TABLES.BACKED_UP is
  3863. 'Has table been backed up since last modification?'
  3864. /
  3865. comment on column DBA_TABLES.NUM_ROWS is
  3866. 'The number of rows in the table'
  3867. /
  3868. comment on column DBA_TABLES.BLOCKS is
  3869. 'The number of used blocks in the table'
  3870. /
  3871. comment on column DBA_TABLES.EMPTY_BLOCKS is
  3872. 'The number of empty (never used) blocks in the table'
  3873. /
  3874. comment on column DBA_TABLES.AVG_SPACE is
  3875. 'The average available free space in the table'
  3876. /
  3877. comment on column DBA_TABLES.CHAIN_CNT is
  3878. 'The number of chained rows in the table'
  3879. /
  3880. comment on column DBA_TABLES.AVG_ROW_LEN is
  3881. 'The average row length, including row overhead'
  3882. /
  3883. comment on column DBA_TABLES.DEGREE is
  3884. 'The number of threads per instance for scanning the table'
  3885. /
  3886. comment on column DBA_TABLES.INSTANCES is
  3887. 'The number of instances across which the table is to be scanned'
  3888. /
  3889. comment on column DBA_TABLES.CACHE is
  3890. 'Whether the table is to be cached in the buffer cache'
  3891. /
  3892. remark
  3893. remark  FAMILY "TABLESPACES"
  3894. remark  CREATE TABLESPACE parameters, except datafiles.
  3895. remark  This family has no ALL member.
  3896. remark
  3897. create or replace view USER_TABLESPACES
  3898.     (TABLESPACE_NAME, INITIAL_EXTENT, NEXT_EXTENT, MIN_EXTENTS,
  3899.      MAX_EXTENTS, PCT_INCREASE,
  3900.      STATUS)
  3901. as select ts.name, ts.blocksize * ts.dflinit,
  3902.                    ts.blocksize * ts.dflincr,
  3903.                    ts.dflminext, ts.dflmaxext, ts.dflextpct,
  3904.           decode(ts.online$, 1, 'ONLINE', 2, 'OFFLINE', 3, 'INVALID',
  3905.                  4, 'READ ONLY', 'UNDEFINED')
  3906. from sys.ts$ ts
  3907. where exists (select null from sys.tsq$ tsq
  3908.               where tsq.ts# = ts.ts#
  3909.                 and tsq.user# = userenv('SCHEMAID') and 
  3910.                 (tsq.blocks > 0 or tsq.maxblocks != 0))
  3911.        or exists
  3912.           (select null
  3913.            from sys.v$enabledprivs
  3914.            where priv_number = -15 /* UNLIMITED TABLESPACE */)
  3915. /
  3916. comment on table USER_TABLESPACES is
  3917. 'Description of accessible tablespaces'
  3918. /
  3919. comment on column USER_TABLESPACES.TABLESPACE_NAME is
  3920. 'Tablespace name'
  3921. /
  3922. comment on column USER_TABLESPACES.INITIAL_EXTENT is
  3923. 'Default initial extent size'
  3924. /
  3925. comment on column USER_TABLESPACES.NEXT_EXTENT is
  3926. 'Default incremental extent size'
  3927. /
  3928. comment on column USER_TABLESPACES.MIN_EXTENTS is
  3929. 'Default minimum number of extents'
  3930. /
  3931. comment on column USER_TABLESPACES.MAX_EXTENTS is
  3932. 'Default maximum number of extents'
  3933. /
  3934. comment on column USER_TABLESPACES.PCT_INCREASE is
  3935. 'Default percent increase for extent size'
  3936. /
  3937. comment on column USER_TABLESPACES.STATUS is
  3938. 'Tablespace status: "ONLINE", "OFFLINE", or "READ ONLY"'
  3939. /
  3940. drop public synonym USER_TABLESPACES
  3941. /
  3942. create public synonym USER_TABLESPACES for USER_TABLESPACES
  3943. /
  3944. grant select on USER_TABLESPACES to PUBLIC with grant option
  3945. /
  3946. create or replace view DBA_TABLESPACES
  3947.     (TABLESPACE_NAME, INITIAL_EXTENT, NEXT_EXTENT, MIN_EXTENTS,
  3948.      MAX_EXTENTS, PCT_INCREASE,
  3949.      STATUS)
  3950. as select ts.name, ts.blocksize * ts.dflinit,
  3951.           ts.blocksize * ts.dflincr, ts.dflminext,
  3952.           ts.dflmaxext, ts.dflextpct,
  3953.           decode(ts.online$, 1, 'ONLINE', 2, 'OFFLINE',
  3954.                  4, 'READ ONLY', 'UNDEFINED')
  3955. from sys.ts$ ts
  3956. where ts.online$ != 3
  3957. /
  3958. comment on table DBA_TABLESPACES is
  3959. 'Description of all tablespaces'
  3960. /
  3961. comment on column DBA_TABLESPACES.TABLESPACE_NAME is
  3962. 'Tablespace name'
  3963. /
  3964. comment on column DBA_TABLESPACES.INITIAL_EXTENT is
  3965. 'Default initial extent size'
  3966. /
  3967. comment on column DBA_TABLESPACES.NEXT_EXTENT is
  3968. 'Default incremental extent size'
  3969. /
  3970. comment on column DBA_TABLESPACES.MIN_EXTENTS is
  3971. 'Default minimum number of extents'
  3972. /
  3973. comment on column DBA_TABLESPACES.MAX_EXTENTS is
  3974. 'Default maximum number of extents'
  3975. /
  3976. comment on column DBA_TABLESPACES.PCT_INCREASE is
  3977. 'Default percent increase for extent size'
  3978. /
  3979. comment on column DBA_TABLESPACES.STATUS is
  3980. 'Tablespace status: "ONLINE", "OFFLINE", or "READ ONLY"'
  3981. /
  3982.  
  3983. remark
  3984. remark  FAMILY "TAB_COLUMNS"
  3985. remark  The columns that make up objects:  Tables, Views, Clusters
  3986. remark  Includes information specified or implied by user in 
  3987. remark  CREATE/ALTER TABLE/VIEW/CLUSTER.
  3988. remark
  3989. create or replace view USER_TAB_COLUMNS
  3990.     (TABLE_NAME,
  3991.      COLUMN_NAME, DATA_TYPE,
  3992.      DATA_LENGTH, DATA_PRECISION, DATA_SCALE, NULLABLE, COLUMN_ID,
  3993.      DEFAULT_LENGTH, DATA_DEFAULT, NUM_DISTINCT, LOW_VALUE, HIGH_VALUE,
  3994.      DENSITY)
  3995. as
  3996. select o.name,
  3997.        c.name,
  3998.        decode(c.type#, 1, 'VARCHAR2',
  3999.                        2, decode(c.scale, null,
  4000.                                  decode(c.precision, null, 'NUMBER', 'FLOAT'),
  4001.                                  'NUMBER'),
  4002.                        8, 'LONG', 9, 'VARCHAR',
  4003.                        12, 'DATE', 23, 'RAW', 24, 'LONG RAW', 
  4004.                        69, 'ROWID',96,'CHAR', 105, 'MLSLABEL',
  4005.                        106, 'MLSLABEL', 'UNDEFINED'),
  4006.        c.length, c.precision, c.scale,
  4007.        decode(sign(c.null$),-1,'D', 0, 'Y', 'N'), c.col#, c.deflength, 
  4008.     c.default$,
  4009.        c.distcnt, c.lowval, c.hival, c.spare2
  4010. from sys.col$ c, sys.obj$ o
  4011. where o.obj# = c.obj#
  4012.   and o.owner# = userenv('SCHEMAID')
  4013.   and o.type in (2, 3, 4)
  4014. /
  4015. comment on table USER_TAB_COLUMNS is
  4016. 'Columns of user''s tables, views and clusters'
  4017. /
  4018. comment on column USER_TAB_COLUMNS.TABLE_NAME is
  4019. 'Table, view or cluster name'
  4020. /
  4021. comment on column USER_TAB_COLUMNS.COLUMN_NAME is
  4022. 'Column name'
  4023. /
  4024. comment on column USER_TAB_COLUMNS.DATA_LENGTH is
  4025. 'Length of the column in bytes'
  4026. /
  4027. comment on column USER_TAB_COLUMNS.DATA_TYPE is
  4028. 'Datatype of the column'
  4029. /
  4030. comment on column USER_TAB_COLUMNS.DATA_PRECISION is
  4031. 'Length: decimal digits (NUMBER) or binary digits (FLOAT)'
  4032. /
  4033. comment on column USER_TAB_COLUMNS.DATA_SCALE is
  4034. 'Digits to right of decimal point in a number'
  4035. /
  4036. comment on column USER_TAB_COLUMNS.NULLABLE is
  4037. 'Does column allow NULL values?'
  4038. /
  4039. comment on column USER_TAB_COLUMNS.COLUMN_ID is
  4040. 'Sequence number of the column as created'
  4041. /
  4042. comment on column USER_TAB_COLUMNS.DEFAULT_LENGTH is
  4043. 'Length of default value for the column'
  4044. /
  4045. comment on column USER_TAB_COLUMNS.DATA_DEFAULT is
  4046. 'Default value for the column'
  4047. /
  4048. comment on column USER_TAB_COLUMNS.NUM_DISTINCT is
  4049. 'The number of distinct values for the column'
  4050. /
  4051. comment on column USER_TAB_COLUMNS.LOW_VALUE is
  4052. 'The second smallest value for the column'
  4053. /
  4054. comment on column USER_TAB_COLUMNS.HIGH_VALUE is
  4055. 'The second highest value for the column'
  4056. /
  4057. comment on column USER_TAB_COLUMNS.DENSITY is
  4058. 'The density of the column'
  4059. /
  4060. drop public synonym USER_TAB_COLUMNS
  4061. /
  4062. create public synonym USER_TAB_COLUMNS for USER_TAB_COLUMNS
  4063. /
  4064. drop public synonym COLS
  4065. /
  4066. create public synonym COLS for USER_TAB_COLUMNS
  4067. /
  4068. grant select on USER_TAB_COLUMNS to PUBLIC with grant option
  4069. /
  4070. create or replace view ALL_TAB_COLUMNS
  4071.     (OWNER, TABLE_NAME,
  4072.      COLUMN_NAME, 
  4073.      DATA_TYPE,
  4074.      DATA_LENGTH, DATA_PRECISION, DATA_SCALE,
  4075.      NULLABLE, COLUMN_ID, DEFAULT_LENGTH, DATA_DEFAULT,
  4076.      NUM_DISTINCT, LOW_VALUE, HIGH_VALUE,DENSITY)
  4077. as
  4078. select u.name, o.name,
  4079.        c.name,
  4080.        decode(c.type#, 1, 'VARCHAR2',
  4081.                        2, decode(c.scale, null,
  4082.                                  decode(c.precision, null, 'NUMBER', 'FLOAT'),
  4083.                                  'NUMBER'),
  4084.                        8, 'LONG', 9, 'VARCHAR',
  4085.                        12, 'DATE', 23, 'RAW', 24, 'LONG RAW',
  4086.                        69, 'ROWID',96,'CHAR', 105, 'MLSLABEL',
  4087.                        106, 'MLSLABEL', 'UNDEFINED'),
  4088.        c.length, c.precision, c.scale,
  4089.        decode(sign(c.null$),-1,'D', 0, 'Y', 'N'), c.col#, c.deflength, 
  4090.     c.default$,
  4091.        c.distcnt, c.lowval, c.hival, c.spare2
  4092. from sys.col$ c, sys.obj$ o, sys.user$ u
  4093. where o.obj# = c.obj#
  4094.   and o.owner# = u.user#
  4095.   and o.type in (2, 3, 4)
  4096.   and (o.owner# = userenv('SCHEMAID')
  4097.         or
  4098.         o.obj# in ( select obj#
  4099.                     from sys.objauth$
  4100.                     where grantee# in ( select kzsrorol
  4101.                                          from x$kzsro
  4102.                                        )
  4103.                   )
  4104.     or /* user has system privileges */
  4105.       exists (select null from v$enabledprivs
  4106.           where priv_number in (-45 /* LOCK ANY TABLE */,
  4107.                     -47 /* SELECT ANY TABLE */,
  4108.                     -48 /* INSERT ANY TABLE */,
  4109.                     -49 /* UPDATE ANY TABLE */,
  4110.                     -50 /* DELETE ANY TABLE */)
  4111.           )
  4112.        )
  4113. /
  4114. comment on table ALL_TAB_COLUMNS is
  4115. 'Columns of all tables, views and clusters'
  4116. /
  4117. comment on column ALL_TAB_COLUMNS.OWNER is
  4118. 'Owner of the table, view or cluster'
  4119. /
  4120. comment on column ALL_TAB_COLUMNS.TABLE_NAME is
  4121. 'Table, view or cluster name'
  4122. /
  4123. comment on column ALL_TAB_COLUMNS.COLUMN_NAME is
  4124. 'Column name'
  4125. /
  4126. comment on column ALL_TAB_COLUMNS.DATA_LENGTH is
  4127. 'Length of the column in bytes'
  4128. /
  4129. comment on column ALL_TAB_COLUMNS.DATA_TYPE is
  4130. 'Datatype of the column'
  4131. /
  4132. comment on column ALL_TAB_COLUMNS.DATA_PRECISION is
  4133. 'Length: decimal digits (NUMBER) or binary digits (FLOAT)'
  4134. /
  4135. comment on column ALL_TAB_COLUMNS.DATA_SCALE is
  4136. 'Digits to right of decimal point in a number'
  4137. /
  4138. comment on column ALL_TAB_COLUMNS.NULLABLE is
  4139. 'Does column allow NULL values?'
  4140. /
  4141. comment on column ALL_TAB_COLUMNS.COLUMN_ID is
  4142. 'Sequence number of the column as created'
  4143. /
  4144. comment on column ALL_TAB_COLUMNS.DEFAULT_LENGTH is
  4145. 'Length of default value for the column'
  4146. /
  4147. comment on column ALL_TAB_COLUMNS.DATA_DEFAULT is
  4148. 'Default value for the column'
  4149. /
  4150. comment on column ALL_TAB_COLUMNS.NUM_DISTINCT is
  4151. 'The number of distinct values for the column'
  4152. /
  4153. comment on column ALL_TAB_COLUMNS.LOW_VALUE is
  4154. 'The second smallest value for the column'
  4155. /
  4156. comment on column ALL_TAB_COLUMNS.HIGH_VALUE is
  4157. 'The second highest value for the column'
  4158. /
  4159. comment on column ALL_TAB_COLUMNS.DENSITY is
  4160. 'The density of the column'
  4161. /
  4162. drop public synonym ALL_TAB_COLUMNS
  4163. /
  4164. create public synonym ALL_TAB_COLUMNS for ALL_TAB_COLUMNS
  4165. /
  4166. grant select on ALL_TAB_COLUMNS to PUBLIC with grant option
  4167. /
  4168. create or replace view DBA_TAB_COLUMNS
  4169.     (OWNER, TABLE_NAME,
  4170.      COLUMN_NAME,
  4171.      DATA_TYPE,
  4172.      DATA_LENGTH, DATA_PRECISION, DATA_SCALE,
  4173.      NULLABLE, COLUMN_ID, DEFAULT_LENGTH, DATA_DEFAULT,
  4174.      NUM_DISTINCT, LOW_VALUE, HIGH_VALUE,DENSITY)
  4175. as
  4176. select u.name, o.name,
  4177.        c.name,
  4178.        decode(c.type#, 1, 'VARCHAR2',
  4179.                        2, decode(c.scale, null,
  4180.                                  decode(c.precision, null, 'NUMBER', 'FLOAT'),
  4181.                                  'NUMBER'),
  4182.                        8, 'LONG', 9, 'VARCHAR',
  4183.                        12, 'DATE', 23, 'RAW', 24, 'LONG RAW',
  4184.                        69, 'ROWID',96,'CHAR', 105, 'MLSLABEL',
  4185.                        106, 'MLSLABEL', 'UNDEFINED'),
  4186.        c.length, c.precision, c.scale,
  4187.        decode(sign(c.null$),-1, 'D', 0, 'Y', 'N'), c.col#, c.deflength, 
  4188.     c.default$,
  4189.        c.distcnt, c.lowval, c.hival,c.spare2
  4190. from sys.col$ c, sys.obj$ o, sys.user$ u
  4191. where o.obj# = c.obj#
  4192.   and o.owner# = u.user#
  4193.   and o.type in (2, 3, 4)
  4194. /
  4195. comment on table DBA_TAB_COLUMNS is
  4196. 'Columns of all tables, views and clusters'
  4197. /
  4198. comment on column DBA_TAB_COLUMNS.OWNER is
  4199. 'Owner of the table, view or cluster'
  4200. /
  4201. comment on column DBA_TAB_COLUMNS.TABLE_NAME is
  4202. 'Table, view or cluster name'
  4203. /
  4204. comment on column DBA_TAB_COLUMNS.COLUMN_NAME is
  4205. 'Column name'
  4206. /
  4207. comment on column DBA_TAB_COLUMNS.DATA_LENGTH is
  4208. 'Length of the column in bytes'
  4209. /
  4210. comment on column DBA_TAB_COLUMNS.DATA_TYPE is
  4211. 'Datatype of the column'
  4212. /
  4213. comment on column DBA_TAB_COLUMNS.DATA_PRECISION is
  4214. 'Length: decimal digits (NUMBER) or binary digits (FLOAT)'
  4215. /
  4216. comment on column DBA_TAB_COLUMNS.DATA_SCALE is
  4217. 'Digits to right of decimal point in a number'
  4218. /
  4219. comment on column DBA_TAB_COLUMNS.NULLABLE is
  4220. 'Does column allow NULL values?'
  4221. /
  4222. comment on column DBA_TAB_COLUMNS.COLUMN_ID is
  4223. 'Sequence number of the column as created'
  4224. /
  4225. comment on column DBA_TAB_COLUMNS.DEFAULT_LENGTH is
  4226. 'Length of default value for the column'
  4227. /
  4228. comment on column DBA_TAB_COLUMNS.DATA_DEFAULT is
  4229. 'Default value for the column'
  4230. /
  4231. comment on column DBA_TAB_COLUMNS.NUM_DISTINCT is
  4232. 'The number of distinct values for the column'
  4233. /
  4234. comment on column DBA_TAB_COLUMNS.LOW_VALUE is
  4235. 'The second smallest value for the column'
  4236. /
  4237. comment on column DBA_TAB_COLUMNS.HIGH_VALUE is
  4238. 'The second highest value for the column'
  4239. /
  4240. comment on column DBA_TAB_COLUMNS.DENSITY is
  4241. 'The density of the column'
  4242. /
  4243. remark
  4244. remark  FAMILY "TAB_COMMENTS"
  4245. remark  Comments on objects.
  4246. remark
  4247. create or replace view USER_TAB_COMMENTS
  4248.     (TABLE_NAME,
  4249.      TABLE_TYPE,
  4250.      COMMENTS)
  4251. as
  4252. select o.name,
  4253.        decode(o.type, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
  4254.                       4, 'VIEW', 5, 'SYNONYM', 'UNDEFINED'),
  4255.        c.comment$
  4256. from sys.obj$ o, sys.com$ c
  4257. where o.owner# = userenv('SCHEMAID')
  4258.   and o.type in (2, 4)
  4259.   and o.obj# = c.obj#(+)
  4260.   and c.col#(+) is null
  4261. /
  4262. comment on table USER_TAB_COMMENTS is
  4263. 'Comments on the tables and views owned by the user'
  4264. /
  4265. comment on column USER_TAB_COMMENTS.TABLE_NAME is
  4266. 'Name of the object'
  4267. /
  4268. comment on column USER_TAB_COMMENTS.TABLE_TYPE is
  4269. 'Type of the object:  "TABLE" or "VIEW"'
  4270. /
  4271. comment on column USER_TAB_COMMENTS.COMMENTS is
  4272. 'Comment on the object'
  4273. /
  4274. drop public synonym USER_TAB_COMMENTS
  4275. /
  4276. create public synonym USER_TAB_COMMENTS for USER_TAB_COMMENTS
  4277. /
  4278. grant select on USER_TAB_COMMENTS to PUBLIC with grant option
  4279. /
  4280. create or replace view ALL_TAB_COMMENTS
  4281.     (OWNER, TABLE_NAME,
  4282.      TABLE_TYPE,
  4283.      COMMENTS)
  4284. as
  4285. select u.name, o.name,
  4286.        decode(o.type, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
  4287.                       4, 'VIEW', 5, 'SYNONYM', 'UNDEFINED'),
  4288.        c.comment$
  4289. from sys.obj$ o, sys.user$ u, sys.com$ c
  4290. where o.owner# = u.user#
  4291.   and o.obj# = c.obj#(+)
  4292.   and c.col#(+) is null
  4293.   and o.type in (2, 4)
  4294.   and (o.owner# = userenv('SCHEMAID')
  4295.         or
  4296.         o.obj# in ( select obj#
  4297.                     from sys.objauth$
  4298.                     where grantee# in ( select kzsrorol
  4299.                                          from x$kzsro
  4300.                                        )
  4301.                   )
  4302.     or /* user has system privileges */
  4303.       exists (select null from v$enabledprivs
  4304.           where priv_number in (-45 /* LOCK ANY TABLE */,
  4305.                     -47 /* SELECT ANY TABLE */,
  4306.                     -48 /* INSERT ANY TABLE */,
  4307.                     -49 /* UPDATE ANY TABLE */,
  4308.                     -50 /* DELETE ANY TABLE */)
  4309.           )
  4310.        )
  4311. /
  4312. comment on table ALL_TAB_COMMENTS is
  4313. 'Comments on tables and views accessible to the user'
  4314. /
  4315. comment on column ALL_TAB_COMMENTS.OWNER is
  4316. 'Owner of the object'
  4317. /
  4318. comment on column ALL_TAB_COMMENTS.TABLE_NAME is
  4319. 'Name of the object'
  4320. /
  4321. comment on column ALL_TAB_COMMENTS.TABLE_TYPE is
  4322. 'Type of the object'
  4323. /
  4324. comment on column ALL_TAB_COMMENTS.COMMENTS is
  4325. 'Comment on the object'
  4326. /
  4327. drop public synonym ALL_TAB_COMMENTS
  4328. /
  4329. create public synonym ALL_TAB_COMMENTS for ALL_TAB_COMMENTS
  4330. /
  4331. grant select on ALL_TAB_COMMENTS to PUBLIC with grant option
  4332. /
  4333. create or replace view DBA_TAB_COMMENTS
  4334.     (OWNER, TABLE_NAME,
  4335.      TABLE_TYPE,
  4336.      COMMENTS)
  4337. as
  4338. select u.name, o.name,
  4339.        decode(o.type, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
  4340.                       4, 'VIEW', 5, 'SYNONYM', 'UNDEFINED'),
  4341.        c.comment$
  4342. from sys.obj$ o, sys.user$ u, sys.com$ c
  4343. where o.owner# = u.user#
  4344.   and o.type in (2, 4)
  4345.   and o.obj# = c.obj#(+)
  4346.   and c.col#(+) is null
  4347. /
  4348. comment on table DBA_TAB_COMMENTS is
  4349. 'Comments on all tables and views in the database'
  4350. /
  4351. comment on column DBA_TAB_COMMENTS.OWNER is
  4352. 'Owner of the object'
  4353. /
  4354. comment on column DBA_TAB_COMMENTS.TABLE_NAME is
  4355. 'Name of the object'
  4356. /
  4357. comment on column DBA_TAB_COMMENTS.TABLE_TYPE is
  4358. 'Type of the object'
  4359. /
  4360. comment on column DBA_TAB_COMMENTS.COMMENTS is
  4361. 'Comment on the object'
  4362. /
  4363. remark
  4364. remark  FAMILY "TAB_PRIVS"
  4365. remark  Grants on objects.
  4366. remark
  4367. create or replace view USER_TAB_PRIVS
  4368.       (GRANTEE, OWNER, TABLE_NAME, GRANTOR, PRIVILEGE, GRANTABLE)
  4369. as
  4370. select ue.name, u.name, o.name, ur.name, tpm.name, 
  4371.        decode(oa.option$, 1, 'YES', 'NO')
  4372. from sys.objauth$ oa, sys.obj$ o, sys.user$ u, sys.user$ ur, sys.user$ ue,
  4373.      table_privilege_map tpm
  4374. where oa.obj# = o.obj#
  4375.   and oa.grantor# = ur.user#
  4376.   and oa.grantee# = ue.user#
  4377.   and oa.col# is null
  4378.   and u.user# = o.owner#
  4379.   and oa.privilege# = tpm.privilege
  4380.   and userenv('SCHEMAID') in (oa.grantor#, oa.grantee#, o.owner#)
  4381. /
  4382. comment on table USER_TAB_PRIVS is
  4383. 'Grants on objects for which the user is the owner, grantor or grantee'
  4384. /
  4385. comment on column USER_TAB_PRIVS.GRANTEE is
  4386. 'Name of the user to whom access was granted'
  4387. /
  4388. comment on column USER_TAB_PRIVS.OWNER is
  4389. 'Owner of the object'
  4390. /
  4391. comment on column USER_TAB_PRIVS.TABLE_NAME is
  4392. 'Name of the object'
  4393. /
  4394. comment on column USER_TAB_PRIVS.GRANTOR is
  4395. 'Name of the user who performed the grant'
  4396. /
  4397. comment on column USER_TAB_PRIVS.PRIVILEGE is
  4398. 'Table Privilege'
  4399. /
  4400. comment on column USER_TAB_PRIVS.GRANTABLE is
  4401. 'Privilege is grantable'
  4402. /
  4403. drop public synonym USER_TAB_PRIVS
  4404. /
  4405. create public synonym USER_TAB_PRIVS for USER_TAB_PRIVS
  4406. /
  4407. grant select on USER_TAB_PRIVS to PUBLIC with grant option
  4408. /
  4409. create or replace view ALL_TAB_PRIVS
  4410.       (GRANTOR, GRANTEE, TABLE_SCHEMA, TABLE_NAME, PRIVILEGE, GRANTABLE)
  4411. as
  4412. select ur.name, ue.name, u.name, o.name, tpm.name, 
  4413.        decode(oa.option$, 1, 'YES', 'NO')
  4414. from sys.objauth$ oa, sys.obj$ o, sys.user$ u, sys.user$ ur, sys.user$ ue,
  4415.      table_privilege_map tpm
  4416. where oa.obj# = o.obj#
  4417.   and oa.grantor# = ur.user#
  4418.   and oa.grantee# = ue.user#
  4419.   and oa.col# is null
  4420.   and u.user# = o.owner#
  4421.   and oa.privilege# = tpm.privilege
  4422.   and (oa.grantor# = userenv('SCHEMAID') or
  4423.        oa.grantee# in (select kzsrorol from x$kzsro) or
  4424.        o.owner# = userenv('SCHEMAID'))
  4425. /
  4426. comment on table ALL_TAB_PRIVS is
  4427. 'Grants on objects for which the user is the grantor, grantee, owner, 
  4428.  or an enabled role or PUBLIC is the grantee'
  4429. /
  4430. comment on column ALL_TAB_PRIVS.GRANTOR is
  4431. 'Name of the user who performed the grant'
  4432. /
  4433. comment on column ALL_TAB_PRIVS.GRANTEE is
  4434. 'Name of the user to whom access was granted'
  4435. /
  4436. comment on column ALL_TAB_PRIVS.TABLE_SCHEMA is
  4437. 'Schema of the object'
  4438. /
  4439. comment on column ALL_TAB_PRIVS.TABLE_NAME is
  4440. 'Name of the object'
  4441. /
  4442. comment on column ALL_TAB_PRIVS.PRIVILEGE is
  4443. 'Table Privilege'
  4444. /
  4445. comment on column ALL_TAB_PRIVS.GRANTABLE is
  4446. 'Privilege is grantable'
  4447. /
  4448. drop public synonym ALL_TAB_PRIVS
  4449. /
  4450. create public synonym ALL_TAB_PRIVS for ALL_TAB_PRIVS
  4451. /
  4452. grant select on ALL_TAB_PRIVS to PUBLIC with grant option
  4453. /
  4454. create or replace view DBA_TAB_PRIVS
  4455.       (GRANTEE, OWNER, TABLE_NAME, GRANTOR, PRIVILEGE, GRANTABLE)
  4456. as
  4457. select ue.name, u.name, o.name, ur.name, tpm.name,
  4458.        decode(oa.option$, 1, 'YES', 'NO')
  4459. from sys.objauth$ oa, sys.obj$ o, sys.user$ u, sys.user$ ur, sys.user$ ue,
  4460.      table_privilege_map tpm
  4461. where oa.obj# = o.obj#
  4462.   and oa.grantor# = ur.user#
  4463.   and oa.grantee# = ue.user#
  4464.   and oa.col# is null
  4465.   and oa.privilege# = tpm.privilege
  4466.   and u.user# = o.owner#
  4467. /
  4468. comment on table DBA_TAB_PRIVS is
  4469. 'All grants on objects in the database'
  4470. /
  4471. comment on column DBA_TAB_PRIVS.GRANTEE is
  4472. 'User to whom access was granted'
  4473. /
  4474. comment on column DBA_TAB_PRIVS.OWNER is
  4475. 'Owner of the object'
  4476. /
  4477. comment on column DBA_TAB_PRIVS.TABLE_NAME is
  4478. 'Name of the object'
  4479. /
  4480. comment on column DBA_TAB_PRIVS.GRANTOR is
  4481. 'Name of the user who performed the grant'
  4482. /
  4483. comment on column DBA_TAB_PRIVS.PRIVILEGE is
  4484. 'Table Privilege'
  4485. /
  4486. comment on column DBA_TAB_PRIVS.GRANTABLE is
  4487. 'Privilege is grantable'
  4488. /
  4489. remark
  4490. remark  FAMILY "TAB_PRIVS_MADE"
  4491. remark  Grants made on objects.
  4492. remark  This family has no DBA member.
  4493. remark
  4494. create or replace view USER_TAB_PRIVS_MADE
  4495.       (GRANTEE, TABLE_NAME, GRANTOR, PRIVILEGE, GRANTABLE)
  4496. as
  4497. select ue.name, o.name, ur.name, tpm.name, 
  4498.        decode(oa.option$, 1, 'YES', 'NO')
  4499. from sys.objauth$ oa, sys.obj$ o, sys.user$ ue, sys.user$ ur,
  4500.      table_privilege_map tpm
  4501. where oa.obj# = o.obj#
  4502.   and oa.grantor# = ur.user#
  4503.   and oa.grantee# = ue.user#
  4504.   and oa.col# is null
  4505.   and oa.privilege# = tpm.privilege
  4506.   and o.owner# = userenv('SCHEMAID')
  4507. /
  4508. comment on table USER_TAB_PRIVS_MADE is
  4509. 'All grants on objects owned by the user'
  4510. /
  4511. comment on column USER_TAB_PRIVS_MADE.GRANTEE is
  4512. 'Name of the user to whom access was granted'
  4513. /
  4514. comment on column USER_TAB_PRIVS_MADE.TABLE_NAME is
  4515. 'Name of the object'
  4516. /
  4517. comment on column USER_TAB_PRIVS_MADE.GRANTOR is
  4518. 'Name of the user who performed the grant'
  4519. /
  4520. comment on column USER_TAB_PRIVS_MADE.PRIVILEGE is
  4521. 'Table Privilege'
  4522. /
  4523. comment on column USER_TAB_PRIVS_MADE.GRANTABLE is
  4524. 'Privilege is grantable'
  4525. /
  4526. drop public synonym USER_TAB_PRIVS_MADE
  4527. /
  4528. create public synonym USER_TAB_PRIVS_MADE for USER_TAB_PRIVS_MADE
  4529. /
  4530. grant select on USER_TAB_PRIVS_MADE to PUBLIC with grant option
  4531. /
  4532. create or replace view ALL_TAB_PRIVS_MADE
  4533.       (GRANTEE, OWNER, TABLE_NAME, GRANTOR, PRIVILEGE, GRANTABLE)
  4534. as
  4535. select ue.name, u.name, o.name, ur.name, tpm.name, 
  4536.        decode(oa.option$, 1, 'YES', 'NO')
  4537. from sys.objauth$ oa, sys.obj$ o, sys.user$ u, sys.user$ ur, sys.user$ ue,
  4538.      table_privilege_map tpm
  4539. where oa.obj# = o.obj#
  4540.   and oa.grantor# = ur.user#
  4541.   and oa.grantee# = ue.user#
  4542.   and u.user# = o.owner#
  4543.   and oa.col# is null
  4544.   and oa.privilege# = tpm.privilege
  4545.   and userenv('SCHEMAID') in (o.owner#, oa.grantor#)
  4546. /
  4547. comment on table ALL_TAB_PRIVS_MADE is
  4548. 'User''s grants and grants on user''s objects'
  4549. /
  4550. comment on column ALL_TAB_PRIVS_MADE.GRANTEE is
  4551. 'Name of the user to whom access was granted'
  4552. /
  4553. comment on column ALL_TAB_PRIVS_MADE.OWNER is
  4554. 'Owner of the object'
  4555. /
  4556. comment on column ALL_TAB_PRIVS_MADE.TABLE_NAME is
  4557. 'Name of the object'
  4558. /
  4559. comment on column ALL_TAB_PRIVS_MADE.GRANTOR is
  4560. 'Name of the user who performed the grant'
  4561. /
  4562. comment on column ALL_TAB_PRIVS_MADE.PRIVILEGE is
  4563. 'Table Privilege'
  4564. /
  4565. comment on column ALL_TAB_PRIVS_MADE.GRANTABLE is
  4566. 'Privilege is grantable'
  4567. /
  4568. drop public synonym ALL_TAB_PRIVS_MADE
  4569. /
  4570. create public synonym ALL_TAB_PRIVS_MADE for ALL_TAB_PRIVS_MADE
  4571. /
  4572. grant select on ALL_TAB_PRIVS_MADE to PUBLIC with grant option
  4573. /
  4574. remark
  4575. remark  FAMILY "TAB_PRIVS_RECD"
  4576. remark  Grants received on objects.
  4577. remark  This family has no DBA member.
  4578. remark
  4579. create or replace view USER_TAB_PRIVS_RECD
  4580.       (OWNER, TABLE_NAME, GRANTOR, PRIVILEGE, GRANTABLE)
  4581. as
  4582. select u.name, o.name, ur.name, tpm.name, 
  4583.        decode(oa.option$, 1, 'YES', 'NO')
  4584. from sys.objauth$ oa, sys.obj$ o, sys.user$ u, sys.user$ ur, 
  4585.      table_privilege_map tpm
  4586. where oa.obj# = o.obj#
  4587.   and oa.grantor# = ur.user#
  4588.   and u.user# = o.owner#
  4589.   and oa.col# is null
  4590.   and oa.privilege# = tpm.privilege
  4591.   and oa.grantee# = userenv('SCHEMAID')
  4592. /
  4593. comment on table USER_TAB_PRIVS_RECD is
  4594. 'Grants on objects for which the user is the grantee'
  4595. /
  4596. comment on column USER_TAB_PRIVS_RECD.OWNER is
  4597. 'Owner of the object'
  4598. /
  4599. comment on column USER_TAB_PRIVS_RECD.TABLE_NAME is
  4600. 'Name of the object'
  4601. /
  4602. comment on column USER_TAB_PRIVS_RECD.GRANTOR is
  4603. 'Name of the user who performed the grant'
  4604. /
  4605. comment on column USER_TAB_PRIVS_RECD.PRIVILEGE is
  4606. 'Table Privilege'
  4607. /
  4608. comment on column USER_TAB_PRIVS_RECD.GRANTABLE is
  4609. 'Privilege is grantable'
  4610. /
  4611. drop public synonym USER_TAB_PRIVS_RECD
  4612. /
  4613. create public synonym USER_TAB_PRIVS_RECD for USER_TAB_PRIVS_RECD
  4614. /
  4615. grant select on USER_TAB_PRIVS_RECD to PUBLIC with grant option
  4616. /
  4617. create or replace view ALL_TAB_PRIVS_RECD
  4618.       (GRANTEE, OWNER, TABLE_NAME, GRANTOR, PRIVILEGE, GRANTABLE)
  4619. as
  4620. select ue.name, u.name, o.name, ur.name, tpm.name, 
  4621.        decode(oa.option$, 1, 'YES', 'NO')
  4622. from sys.objauth$ oa, sys.obj$ o, sys.user$ u, sys.user$ ur, sys.user$ ue,
  4623.      table_privilege_map tpm
  4624. where oa.obj# = o.obj#
  4625.   and oa.grantor# = ur.user#
  4626.   and oa.grantee# = ue.user#
  4627.   and u.user# = o.owner#
  4628.   and oa.col# is null
  4629.   and oa.privilege# = tpm.privilege
  4630.   and oa.grantee# in (select kzsrorol from x$kzsro)
  4631. /
  4632. comment on table ALL_TAB_PRIVS_RECD is
  4633. 'Grants on objects for which the user, PUBLIC or enabled role is the grantee'
  4634. /
  4635. comment on column ALL_TAB_PRIVS_RECD.GRANTEE is
  4636. 'Name of the user to whom access was granted'
  4637. /
  4638. comment on column ALL_TAB_PRIVS_RECD.OWNER is
  4639. 'Owner of the object'
  4640. /
  4641. comment on column ALL_TAB_PRIVS_RECD.TABLE_NAME is
  4642. 'Name of the object'
  4643. /
  4644. comment on column ALL_TAB_PRIVS_RECD.GRANTOR is
  4645. 'Name of the user who performed the grant'
  4646. /
  4647. comment on column ALL_TAB_PRIVS_RECD.PRIVILEGE is
  4648. 'Table Privilege'
  4649. /
  4650. comment on column ALL_TAB_PRIVS_RECD.GRANTABLE is
  4651. 'Privilege is grantable'
  4652. /
  4653. drop public synonym ALL_TAB_PRIVS_RECD
  4654. /
  4655. create public synonym ALL_TAB_PRIVS_RECD for ALL_TAB_PRIVS_RECD
  4656. /
  4657. grant select on ALL_TAB_PRIVS_RECD to PUBLIC with grant option
  4658. /
  4659. remark
  4660. remark  FAMILY "TS_QUOTAS"
  4661. remark  Tablespace quotas for users.
  4662. remark  This family has no ALL member.
  4663. remark
  4664. create or replace view USER_TS_QUOTAS
  4665.     (TABLESPACE_NAME, BYTES, MAX_BYTES, BLOCKS, MAX_BLOCKS)
  4666. as
  4667. select ts.name, q.blocks * ts.blocksize,
  4668.        decode(q.maxblocks, -1, -1, q.maxblocks * ts.blocksize),
  4669.        q.blocks, q.maxblocks
  4670. from sys.tsq$ q, sys.ts$ ts
  4671. where q.ts# = ts.ts#
  4672.   and q.user# = userenv('SCHEMAID')
  4673. /
  4674. comment on table USER_TS_QUOTAS is
  4675. 'Tablespace quotas for the user'
  4676. /
  4677. comment on column USER_TS_QUOTAS.TABLESPACE_NAME is
  4678. 'Tablespace name'
  4679. /
  4680. comment on column USER_TS_QUOTAS.BLOCKS is
  4681. 'Number of ORACLE blocks charged to the user'
  4682. /
  4683. comment on column USER_TS_QUOTAS.MAX_BLOCKS is
  4684. 'User''s quota in ORACLE blocks.  NULL if no limit'
  4685. /
  4686. comment on column USER_TS_QUOTAS.BYTES is
  4687. 'Number of bytes charged to the user'
  4688. /
  4689. comment on column USER_TS_QUOTAS.MAX_BYTES is
  4690. 'User''s quota in bytes.  NULL if no limit'
  4691. /
  4692. drop public synonym USER_TS_QUOTAS
  4693. /
  4694. create public synonym USER_TS_QUOTAS for USER_TS_QUOTAS
  4695. /
  4696. grant select on USER_TS_QUOTAS to PUBLIC with grant option
  4697. /
  4698. create or replace view DBA_TS_QUOTAS
  4699.     (TABLESPACE_NAME, USERNAME, BYTES, MAX_BYTES, BLOCKS, MAX_BLOCKS)
  4700. as
  4701. select ts.name, u.name, 
  4702.        q.blocks * ts.blocksize, 
  4703.        decode(q.maxblocks, -1, -1, q.maxblocks * ts.blocksize),
  4704.        q.blocks, q.maxblocks
  4705. from sys.tsq$ q, sys.ts$ ts, sys.user$ u
  4706. where q.ts# = ts.ts#
  4707.   and q.user# = u.user#
  4708.   and q.maxblocks != 0
  4709. /
  4710. comment on table DBA_TS_QUOTAS is
  4711. 'Tablespace quotas for all users'
  4712. /
  4713. comment on column DBA_TS_QUOTAS.TABLESPACE_NAME is
  4714. 'Tablespace name'
  4715. /
  4716. comment on column DBA_TS_QUOTAS.USERNAME is
  4717. 'User with resource rights on the tablespace'
  4718. /
  4719. comment on column DBA_TS_QUOTAS.BLOCKS is
  4720. 'Number of ORACLE blocks charged to the user'
  4721. /
  4722. comment on column DBA_TS_QUOTAS.MAX_BLOCKS is
  4723. 'User''s quota in ORACLE blocks.  NULL if no limit'
  4724. /
  4725. comment on column DBA_TS_QUOTAS.BYTES is
  4726. 'Number of bytes charged to the user'
  4727. /
  4728. comment on column DBA_TS_QUOTAS.MAX_BYTES is
  4729. 'User''s quota in bytes.  NULL if no limit'
  4730. /
  4731. remark
  4732. remark  FAMILY "USERS"
  4733. remark  Users enrolled in the database.
  4734. remark
  4735. create or replace view USER_USERS
  4736.     (USERNAME, USER_ID,
  4737.      DEFAULT_TABLESPACE, TEMPORARY_TABLESPACE, CREATED)
  4738. as
  4739. select u.name, u.user#,
  4740.        dts.name, tts.name, u.ctime
  4741. from sys.user$ u, sys.ts$ dts, sys.ts$ tts
  4742. where u.datats# = dts.ts#
  4743.   and u.tempts# = tts.ts#
  4744.   and u.type = 1
  4745.   and u.user# = userenv('SCHEMAID')
  4746. /
  4747. comment on table USER_USERS is
  4748. 'Information about the current user'
  4749. /
  4750. comment on column USER_USERS.USERNAME is
  4751. 'Name of the user'
  4752. /
  4753. comment on column USER_USERS.USER_ID is
  4754. 'ID number of the user'
  4755. /
  4756. comment on column USER_USERS.DEFAULT_TABLESPACE is
  4757. 'Default tablespace for data'
  4758. /
  4759. comment on column USER_USERS.TEMPORARY_TABLESPACE is
  4760. 'Default tablespace for temporary tables'
  4761. /
  4762. comment on column USER_USERS.CREATED is
  4763. 'User creation date'
  4764. /
  4765. drop public synonym USER_USERS
  4766. /
  4767. create public synonym USER_USERS for USER_USERS
  4768. /
  4769. grant select on USER_USERS to PUBLIC with grant option
  4770. /
  4771. create or replace view ALL_USERS
  4772.     (USERNAME, USER_ID, CREATED)
  4773. as
  4774. select u.name, u.user#, u.ctime
  4775. from sys.user$ u, sys.ts$ dts, sys.ts$ tts
  4776. where u.datats# = dts.ts#
  4777.   and u.tempts# = tts.ts#
  4778.   and u.type = 1
  4779. /
  4780. comment on table ALL_USERS is
  4781. 'Information about all users of the database'
  4782. /
  4783. comment on column ALL_USERS.USERNAME is
  4784. 'Name of the user'
  4785. /
  4786. comment on column ALL_USERS.USER_ID is
  4787. 'ID number of the user'
  4788. /
  4789. comment on column ALL_USERS.CREATED is
  4790. 'User creation date'
  4791. /
  4792. drop public synonym ALL_USERS
  4793. /
  4794. create public synonym ALL_USERS for ALL_USERS
  4795. /
  4796. grant select on ALL_USERS to PUBLIC with grant option
  4797. /
  4798. create or replace view DBA_USERS
  4799.     (USERNAME, USER_ID, PASSWORD,
  4800.      DEFAULT_TABLESPACE, TEMPORARY_TABLESPACE, CREATED, PROFILE)
  4801. as
  4802. select u.name, u.user#, u.password,
  4803.        dts.name, tts.name, u.ctime, p.name
  4804. from sys.user$ u, sys.ts$ dts, sys.ts$ tts, sys.profname$ p
  4805. where u.datats# = dts.ts#
  4806.   and u.resource$ = p.profile#
  4807.   and u.tempts# = tts.ts#
  4808.   and u.type = 1
  4809. /
  4810. comment on table DBA_USERS is
  4811. 'Information about all users of the database'
  4812. /
  4813. comment on column DBA_USERS.USERNAME is
  4814. 'Name of the user'
  4815. /
  4816. comment on column DBA_USERS.USER_ID is
  4817. 'ID number of the user'
  4818. /
  4819. comment on column DBA_USERS.PASSWORD is
  4820. 'Encrypted password'
  4821. /
  4822. comment on column DBA_USERS.DEFAULT_TABLESPACE is
  4823. 'Default tablespace for data'
  4824. /
  4825. comment on column DBA_USERS.TEMPORARY_TABLESPACE is
  4826. 'Default tablespace for temporary tables'
  4827. /
  4828. comment on column DBA_USERS.CREATED is
  4829. 'User creation date'
  4830. /
  4831. comment on column DBA_USERS.PROFILE is
  4832. 'User resource profile name'
  4833. /
  4834. remark
  4835. remark  FAMILY "VIEWS"
  4836. remark  All relevant information about views, except columns.
  4837. remark
  4838. create or replace view USER_VIEWS
  4839.     (VIEW_NAME, TEXT_LENGTH, TEXT)
  4840. as
  4841. select o.name, v.textlength, v.text
  4842. from sys.obj$ o, sys.view$ v
  4843. where o.obj# = v.obj#
  4844.   and o.owner# = userenv('SCHEMAID')
  4845. /
  4846. comment on table USER_VIEWS is
  4847. 'Text of views owned by the user'
  4848. /
  4849. comment on column USER_VIEWS.VIEW_NAME is
  4850. 'Name of the view'
  4851. /
  4852. comment on column USER_VIEWS.TEXT_LENGTH is
  4853. 'Length of the view text'
  4854. /
  4855. comment on column USER_VIEWS.TEXT is
  4856. 'View text'
  4857. /
  4858. drop public synonym USER_VIEWS
  4859. /
  4860. create public synonym USER_VIEWS for USER_VIEWS
  4861. /
  4862. grant select on USER_VIEWS to PUBLIC with grant option
  4863. /
  4864. create or replace view ALL_VIEWS
  4865.     (OWNER, VIEW_NAME, TEXT_LENGTH, TEXT)
  4866. as
  4867. select u.name, o.name, v.textlength, v.text
  4868. from sys.obj$ o, sys.view$ v, sys.user$ u
  4869. where o.obj# = v.obj#
  4870.   and o.owner# = u.user#
  4871.   and (o.owner# = userenv('SCHEMAID')
  4872.        or o.obj# in
  4873.             (select oa.obj#
  4874.              from sys.objauth$ oa
  4875.              where oa.grantee# in ( select kzsrorol
  4876.                                          from x$kzsro
  4877.                                   )
  4878.             )
  4879.     or /* user has system privileges */
  4880.       exists (select null from v$enabledprivs
  4881.           where priv_number in (-45 /* LOCK ANY TABLE */,
  4882.                     -47 /* SELECT ANY TABLE */,
  4883.                     -48 /* INSERT ANY TABLE */,
  4884.                     -49 /* UPDATE ANY TABLE */,
  4885.                     -50 /* DELETE ANY TABLE */)
  4886.           )
  4887.       )
  4888. /
  4889. comment on table ALL_VIEWS is
  4890. 'Text of views accessible to the user'
  4891. /
  4892. comment on column ALL_VIEWS.OWNER is
  4893. 'Owner of the view'
  4894. /
  4895. comment on column ALL_VIEWS.VIEW_NAME is
  4896. 'Name of the view'
  4897. /
  4898. comment on column ALL_VIEWS.TEXT_LENGTH is
  4899. 'Length of the view text'
  4900. /
  4901. comment on column ALL_VIEWS.TEXT is
  4902. 'View text'
  4903. /
  4904. drop public synonym ALL_VIEWS
  4905. /
  4906. create public synonym ALL_VIEWS for ALL_VIEWS
  4907. /
  4908. grant select on ALL_VIEWS to PUBLIC with grant option
  4909. /
  4910. create or replace view DBA_VIEWS
  4911.     (OWNER, VIEW_NAME, TEXT_LENGTH, TEXT)
  4912. as
  4913. select u.name, o.name, v.textlength, v.text
  4914. from sys.obj$ o, sys.view$ v, sys.user$ u
  4915. where o.obj# = v.obj#
  4916.   and o.owner# = u.user#
  4917. /
  4918. comment on table DBA_VIEWS is
  4919. 'Text of all views in the database'
  4920. /
  4921. comment on column DBA_VIEWS.OWNER is
  4922. 'Owner of the view'
  4923. /
  4924. comment on column DBA_VIEWS.VIEW_NAME is
  4925. 'Name of the view'
  4926. /
  4927. comment on column DBA_VIEWS.TEXT_LENGTH is
  4928. 'Length of the view text'
  4929. /
  4930. comment on column DBA_VIEWS.TEXT is
  4931. 'View text'
  4932. /
  4933. remark
  4934. remark  FAMILY "CONSTRAINTS"
  4935. remark
  4936. create or replace view USER_CONSTRAINTS 
  4937.     (OWNER, CONSTRAINT_NAME, CONSTRAINT_TYPE,
  4938.      TABLE_NAME, SEARCH_CONDITION, R_OWNER,
  4939.      R_CONSTRAINT_NAME, DELETE_RULE, STATUS)
  4940. as
  4941. select ou.name, oc.name,
  4942.        decode(c.type, 1, 'C', 2, 'P', 3, 'U',
  4943.               4, 'R', 5, 'V',7,'C', '?'),
  4944.        o.name, c.condition, ru.name, rc.name, 
  4945.        decode(c.type, 4,
  4946.               decode(c.refact, 1, 'CASCADE', 'NO ACTION'), NULL),
  4947.        decode(c.type, 5, 'ENABLED',
  4948.               decode(c.enabled, NULL, 'DISABLED','ENABLED'))
  4949. from sys.con$ oc, sys.con$ rc, sys.user$ ou, sys.user$ ru,
  4950.      sys.obj$ o, sys.cdef$ c
  4951. where oc.owner# = ou.user#
  4952.   and oc.con# = c.con#
  4953.   and c.obj# = o.obj#
  4954.   and c.rcon# = rc.con#(+)
  4955.   and rc.owner# = ru.user#(+)
  4956.   and o.owner# = userenv('SCHEMAID')
  4957. /
  4958. comment on table USER_CONSTRAINTS is
  4959. 'Constraint definitions on user''s own tables'
  4960. /
  4961. comment on column USER_CONSTRAINTS.OWNER is
  4962. 'Owner of the table'
  4963. /
  4964. comment on column USER_CONSTRAINTS.CONSTRAINT_NAME is
  4965. 'Name associated with constraint definition'
  4966. /
  4967. comment on column USER_CONSTRAINTS.CONSTRAINT_TYPE is
  4968. 'Type of constraint definition'
  4969. /
  4970. comment on column USER_CONSTRAINTS.TABLE_NAME is
  4971. 'Name associated with table with constraint definition'
  4972. /
  4973. comment on column USER_CONSTRAINTS.SEARCH_CONDITION is
  4974. 'Text of search condition for table check'
  4975. /
  4976. comment on column USER_CONSTRAINTS.R_OWNER is
  4977. 'Owner of table used in referential constraint'
  4978. /
  4979. comment on column USER_CONSTRAINTS.R_CONSTRAINT_NAME is
  4980. 'Name of unique constraint definition for referenced table'
  4981. /
  4982. comment on column USER_CONSTRAINTS.DELETE_RULE is
  4983. 'The delete rule for a referential constraint'
  4984. /
  4985. comment on column USER_CONSTRAINTS.STATUS is
  4986. 'enforcement status of constraint -  ENABLED or DISABLED'
  4987. /
  4988. grant select on USER_CONSTRAINTS to public with grant option
  4989. /
  4990. drop public synonym USER_CONSTRAINTS
  4991. /
  4992. create public synonym USER_CONSTRAINTS for USER_CONSTRAINTS
  4993. /
  4994. create or replace view ALL_CONSTRAINTS 
  4995.     (OWNER, CONSTRAINT_NAME, CONSTRAINT_TYPE,
  4996.      TABLE_NAME, SEARCH_CONDITION, R_OWNER,
  4997.      R_CONSTRAINT_NAME, DELETE_RULE, STATUS)
  4998. as
  4999. select ou.name, oc.name,
  5000.        decode(c.type, 1, 'C', 2, 'P', 3, 'U',
  5001.               4, 'R', 5, 'V',7,'C', '?'),
  5002.        o.name, c.condition, ru.name, rc.name,
  5003.        decode(c.type, 4,
  5004.               decode(c.refact, 1, 'CASCADE', 'NO ACTION'), NULL),
  5005.        decode(c.type, 5, 'ENABLED',
  5006.               decode(c.enabled, NULL, 'DISABLED','ENABLED'))
  5007. from sys.con$ oc, sys.con$ rc, sys.user$ ou, sys.user$ ru,
  5008.      sys.obj$ o, sys.cdef$ c
  5009. where oc.owner# = ou.user#
  5010.   and oc.con# = c.con#
  5011.   and c.obj# = o.obj#
  5012.   and c.rcon# = rc.con#(+)
  5013.   and rc.owner# = ru.user#(+)
  5014.   and (o.owner# = userenv('SCHEMAID')
  5015.        or o.obj# in (select obj#
  5016.                      from sys.objauth$
  5017.                      where grantee# in ( select kzsrorol
  5018.                                          from x$kzsro
  5019.                                        )
  5020.                     )
  5021.     or /* user has system privileges */
  5022.       exists (select null from v$enabledprivs
  5023.           where priv_number in (-45 /* LOCK ANY TABLE */,
  5024.                     -47 /* SELECT ANY TABLE */,
  5025.                     -48 /* INSERT ANY TABLE */,
  5026.                     -49 /* UPDATE ANY TABLE */,
  5027.                     -50 /* DELETE ANY TABLE */)
  5028.           )
  5029.       )
  5030. /
  5031. comment on table ALL_CONSTRAINTS is
  5032. 'Constraint definitions on accessible tables'
  5033. /
  5034. comment on column ALL_CONSTRAINTS.OWNER is
  5035. 'Owner of the table'
  5036. /
  5037. comment on column ALL_CONSTRAINTS.CONSTRAINT_NAME is
  5038. 'Name associated with constraint definition'
  5039. /
  5040. comment on column ALL_CONSTRAINTS.CONSTRAINT_TYPE is
  5041. 'Type of constraint definition'
  5042. /
  5043. comment on column ALL_CONSTRAINTS.TABLE_NAME is
  5044. 'Name associated with table with constraint definition'
  5045. /
  5046. comment on column ALL_CONSTRAINTS.SEARCH_CONDITION is
  5047. 'Text of search condition for table check'
  5048. /
  5049. comment on column ALL_CONSTRAINTS.R_OWNER is
  5050. 'Owner of table used in referential constraint'
  5051. /
  5052. comment on column ALL_CONSTRAINTS.R_CONSTRAINT_NAME is
  5053. 'Name of unique constraint definition for referenced table'
  5054. /
  5055. comment on column ALL_CONSTRAINTS.DELETE_RULE is
  5056. 'The delete rule for a referential constraint'
  5057. /
  5058. comment on column ALL_CONSTRAINTS.STATUS is
  5059. 'enforcement status of constraint - ENABLED or DISABLED'
  5060. /
  5061. grant select on ALL_CONSTRAINTS to public with grant option
  5062. /
  5063. drop public synonym ALL_CONSTRAINTS
  5064. /
  5065. create public synonym ALL_CONSTRAINTS for ALL_CONSTRAINTS
  5066. /
  5067. create or replace view DBA_CONSTRAINTS 
  5068.     (OWNER, CONSTRAINT_NAME, CONSTRAINT_TYPE,
  5069.      TABLE_NAME, SEARCH_CONDITION, R_OWNER,
  5070.      R_CONSTRAINT_NAME, DELETE_RULE, STATUS)
  5071. as
  5072. select ou.name, oc.name,
  5073.        decode(c.type, 1, 'C', 2, 'P', 3, 'U',
  5074.               4, 'R', 5, 'V',7,'C', '?'),
  5075.        o.name, c.condition, ru.name, rc.name, 
  5076.        decode(c.type, 4,
  5077.               decode(c.refact, 1, 'CASCADE', 'NO ACTION'), NULL),
  5078.        decode(c.type, 5, 'ENABLED',
  5079.               decode(c.enabled, NULL, 'DISABLED','ENABLED'))
  5080. from sys.con$ oc, sys.con$ rc, sys.user$ ou, sys.user$ ru,
  5081.      sys.obj$ o, sys.cdef$ c
  5082. where oc.owner# = ou.user#
  5083.   and oc.con# = c.con#
  5084.   and c.obj# = o.obj#
  5085.   and c.rcon# = rc.con#(+)
  5086.   and rc.owner# = ru.user#(+)
  5087. /
  5088. comment on table DBA_CONSTRAINTS is
  5089. 'Constraint definitions on all tables'
  5090. /
  5091. comment on column DBA_CONSTRAINTS.OWNER is
  5092. 'Owner of the table'
  5093. /
  5094. comment on column DBA_CONSTRAINTS.CONSTRAINT_NAME is
  5095. 'Name associated with constraint definition'
  5096. /
  5097. comment on column DBA_CONSTRAINTS.CONSTRAINT_TYPE is
  5098. 'Type of constraint definition'
  5099. /
  5100. comment on column DBA_CONSTRAINTS.TABLE_NAME is
  5101. 'Name associated with table with constraint definition'
  5102. /
  5103. comment on column DBA_CONSTRAINTS.SEARCH_CONDITION is
  5104. 'Text of search condition for table check'
  5105. /
  5106. comment on column DBA_CONSTRAINTS.R_OWNER is
  5107. 'Owner of table used in referential constraint'
  5108. /
  5109. comment on column DBA_CONSTRAINTS.R_CONSTRAINT_NAME is
  5110. 'Name of unique constraint definition for referenced table'
  5111. /
  5112. comment on column DBA_CONSTRAINTS.DELETE_RULE is
  5113. 'The delete rule for a referential constraint'
  5114. /
  5115. comment on column DBA_CONSTRAINTS.STATUS is
  5116. 'enforcement status of constraint - ENABLED or DISABLED'
  5117. /
  5118. remark
  5119. remark  FAMILY "CONS_COLUMNS"
  5120. remark
  5121. create or replace view USER_CONS_COLUMNS 
  5122.     (OWNER, CONSTRAINT_NAME, TABLE_NAME, COLUMN_NAME, POSITION)
  5123. as
  5124. select u.name, c.name, o.name, col.name, cc.pos#
  5125. from sys.user$ u, sys.con$ c, sys.col$ col, sys.ccol$ cc, sys.cdef$ cd,
  5126.      sys.obj$ o
  5127. where c.owner# = u.user#
  5128.   and c.con# = cd.con#
  5129.   and cd.con# = cc.con#
  5130.   and cc.obj# = col.obj#
  5131.   and cc.col# = col.col#
  5132.   and cc.obj# = o.obj#
  5133.   and c.owner# = userenv('SCHEMAID')
  5134. /
  5135. comment on table USER_CONS_COLUMNS is
  5136. 'Information about accessible columns in constraint definitions'
  5137. /
  5138. comment on column USER_CONS_COLUMNS.OWNER is
  5139. 'Owner of the constraint definition'
  5140. /
  5141. comment on column USER_CONS_COLUMNS.CONSTRAINT_NAME is
  5142. 'Name associated with the constraint definition'
  5143. /
  5144. comment on column USER_CONS_COLUMNS.TABLE_NAME is
  5145. 'Name associated with table with constraint definition'
  5146. /
  5147. comment on column USER_CONS_COLUMNS.COLUMN_NAME is
  5148. 'Name associated with column specified in the constraint definition'
  5149. /
  5150. comment on column USER_CONS_COLUMNS.POSITION is
  5151. 'Original position of column in definition'
  5152. /
  5153. grant select on USER_CONS_COLUMNS to public with grant option
  5154. /
  5155. drop public synonym USER_CONS_COLUMNS
  5156. /
  5157. create public synonym USER_CONS_COLUMNS for USER_CONS_COLUMNS
  5158. /
  5159. create or replace view ALL_CONS_COLUMNS 
  5160.     (OWNER, CONSTRAINT_NAME, TABLE_NAME, COLUMN_NAME, POSITION)
  5161. as
  5162. select u.name, c.name, o.name, col.name, cc.pos#
  5163. from sys.user$ u, sys.con$ c, sys.col$ col, sys.ccol$ cc, sys.cdef$ cd,
  5164.      sys.obj$ o
  5165. where c.owner# = u.user#
  5166.   and c.con# = cd.con#
  5167.   and cd.con# = cc.con#
  5168.   and cc.obj# = col.obj#
  5169.   and cc.col# = col.col#
  5170.   and cc.obj# = o.obj#
  5171.   and (c.owner# = userenv('SCHEMAID')
  5172.        or cd.obj# in (select obj#
  5173.                       from sys.objauth$
  5174.                       where grantee# in ( select kzsrorol
  5175.                                          from x$kzsro
  5176.                                        )
  5177.                      )
  5178.     or /* user has system privileges */
  5179.       exists (select null from v$enabledprivs
  5180.           where priv_number in (-45 /* LOCK ANY TABLE */,
  5181.                     -47 /* SELECT ANY TABLE */,
  5182.                     -48 /* INSERT ANY TABLE */,
  5183.                     -49 /* UPDATE ANY TABLE */,
  5184.                     -50 /* DELETE ANY TABLE */)
  5185.           )
  5186.       )
  5187. /
  5188. comment on table ALL_CONS_COLUMNS is
  5189. 'Information about accessible columns in constraint definitions'
  5190. /
  5191. comment on column ALL_CONS_COLUMNS.OWNER is
  5192. 'Owner of the constraint definition'
  5193. /
  5194. comment on column ALL_CONS_COLUMNS.CONSTRAINT_NAME is
  5195. 'Name associated with the constraint definition'
  5196. /
  5197. comment on column ALL_CONS_COLUMNS.TABLE_NAME is
  5198. 'Name associated with table with constraint definition'
  5199. /
  5200. comment on column ALL_CONS_COLUMNS.COLUMN_NAME is
  5201. 'Name associated with column specified in the constraint definition'
  5202. /
  5203. comment on column ALL_CONS_COLUMNS.POSITION is
  5204. 'Original position of column in definition'
  5205. /
  5206. grant select on ALL_CONS_COLUMNS to public with grant option
  5207. /
  5208. drop public synonym ALL_CONS_COLUMNS
  5209. /
  5210. create public synonym ALL_CONS_COLUMNS for ALL_CONS_COLUMNS
  5211. /
  5212. create or replace view DBA_CONS_COLUMNS 
  5213.     (OWNER, CONSTRAINT_NAME, TABLE_NAME, COLUMN_NAME, POSITION)
  5214. as
  5215. select u.name, c.name, o.name, col.name, cc.pos#
  5216. from sys.user$ u, sys.con$ c, sys.col$ col, sys.ccol$ cc, sys.cdef$ cd,
  5217.      sys.obj$ o
  5218. where c.owner# = u.user#
  5219.   and c.con# = cd.con#
  5220.   and cd.con# = cc.con#
  5221.   and cc.obj# = col.obj#
  5222.   and cc.col# = col.col#
  5223.   and cc.obj# = o.obj#
  5224. /
  5225. comment on table DBA_CONS_COLUMNS is
  5226. 'Information about accessible columns in constraint definitions'
  5227. /
  5228. comment on column DBA_CONS_COLUMNS.OWNER is
  5229. 'Owner of the constraint definition'
  5230. /
  5231. comment on column DBA_CONS_COLUMNS.CONSTRAINT_NAME is
  5232. 'Name associated with the constraint definition'
  5233. /
  5234. comment on column DBA_CONS_COLUMNS.TABLE_NAME is
  5235. 'Name associated with table with constraint definition'
  5236. /
  5237. comment on column DBA_CONS_COLUMNS.COLUMN_NAME is
  5238. 'Name associated with column specified in the constraint definition'
  5239. /
  5240. comment on column DBA_CONS_COLUMNS.POSITION is
  5241. 'Original position of column in definition'
  5242. /
  5243.  
  5244. remark
  5245. remark  FAMILY "NLS"
  5246. remark
  5247.  
  5248. create or replace view NLS_SESSION_PARAMETERS (PARAMETER, VALUE) as
  5249. select substr(parameter, 1, 30), 
  5250.        substr(value, 1, 30) 
  5251. from v$nls_parameters
  5252. where parameter != 'NLS_CHARACTERSET'
  5253. /
  5254. comment on table NLS_SESSION_PARAMETERS is
  5255. 'NLS parameters of the user session'
  5256. /
  5257. comment on column NLS_SESSION_PARAMETERS.PARAMETER is
  5258. 'Parameter name'
  5259. /
  5260. comment on column NLS_SESSION_PARAMETERS.VALUE is
  5261. 'Parameter value'
  5262. /
  5263. drop public synonym NLS_SESSION_PARAMETERS
  5264. /
  5265. create public synonym NLS_SESSION_PARAMETERS for NLS_SESSION_PARAMETERS
  5266. /
  5267. grant select on NLS_SESSION_PARAMETERS to PUBLIC with grant option
  5268. /
  5269. create or replace view NLS_INSTANCE_PARAMETERS (PARAMETER, VALUE) as
  5270. select substr(upper(name), 1, 30), 
  5271.        substr(value, 1, 30) 
  5272. from v$parameter 
  5273. where name like 'nls%'
  5274. /
  5275. comment on table NLS_INSTANCE_PARAMETERS is
  5276. 'NLS parameters of the instance'
  5277. /
  5278. comment on column NLS_INSTANCE_PARAMETERS.PARAMETER is
  5279. 'Parameter name'
  5280. /
  5281. comment on column NLS_INSTANCE_PARAMETERS.VALUE is
  5282. 'Parameter value'
  5283. /
  5284. drop public synonym NLS_INSTANCE_PARAMETERS
  5285. /
  5286. create public synonym NLS_INSTANCE_PARAMETERS for NLS_INSTANCE_PARAMETERS
  5287. /
  5288. grant select on NLS_INSTANCE_PARAMETERS to PUBLIC with grant option
  5289. /
  5290. create or replace view NLS_DATABASE_PARAMETERS (PARAMETER, VALUE) as
  5291. select name, 
  5292.        substr(value$, 1, 30)
  5293. from props$ 
  5294. where name like 'NLS%'
  5295. /
  5296. comment on table NLS_DATABASE_PARAMETERS is
  5297. 'Permanent NLS parameters of the database'
  5298. /
  5299. comment on column NLS_DATABASE_PARAMETERS.PARAMETER is
  5300. 'Parameter name'
  5301. /
  5302. comment on column NLS_DATABASE_PARAMETERS.VALUE is
  5303. 'Parameter value'
  5304. /
  5305. drop public synonym NLS_DATABASE_PARAMETERS
  5306. /
  5307. create public synonym NLS_DATABASE_PARAMETERS for NLS_DATABASE_PARAMETERS
  5308. /
  5309. grant select on NLS_DATABASE_PARAMETERS to PUBLIC with grant option
  5310. /
  5311.  
  5312. rem 
  5313. rem V5 views required for other Oracle products
  5314. rem
  5315.  
  5316. create or replace view syscatalog_ 
  5317.     (tname, creator, creatorid, tabletype, remarks)
  5318.   as
  5319.   select o.name, u.name, o.owner#,
  5320.          decode(o.type, 2, 'TABLE', 4, 'VIEW', 6, 'SEQUENCE','?'), c.comment$
  5321.   from    sys.user$ u, sys.obj$ o, sys.com$ c
  5322.   where u.user# = o.owner#
  5323.     and    o.type in (2, 4, 6)
  5324.     and o.linkname is null
  5325.     and o.obj# = c.obj#(+)
  5326.     and ( o.owner# = userenv('SCHEMAID')
  5327.       or o.obj# in
  5328.          (select oa.obj#
  5329.           from   sys.objauth$ oa
  5330.           where  oa.grantee# in (userenv('SCHEMAID'), 1)
  5331.           )
  5332.       or
  5333.       (
  5334.       o.type in (2, 4) /* table, view */
  5335.       and
  5336.       exists (select null from v$enabledprivs
  5337.           where priv_number in (-45 /* LOCK ANY TABLE */,
  5338.                     -47 /* SELECT ANY TABLE */,
  5339.                     -48 /* INSERT ANY TABLE */,
  5340.                     -49 /* UPDATE ANY TABLE */,
  5341.                     -50 /* DELETE ANY TABLE */)
  5342.           )
  5343.        )
  5344.       or
  5345.      ( o.type = 6 /* sequence */
  5346.        and
  5347.        exists (select null from v$enabledprivs
  5348.            where priv_number = -109 /* SELECT ANY SEQUENCE */)
  5349.      )
  5350.        )
  5351. /
  5352. create or replace view syscatalog (tname, creator, tabletype, remarks) as
  5353.   select tname, creator, tabletype, remarks
  5354.   from syscatalog_
  5355. /
  5356. grant select on syscatalog to public with grant option;
  5357. drop synonym system.syscatalog;
  5358. create synonym system.syscatalog for syscatalog;
  5359. rem
  5360. rem The catalog view returns almost all tables accessible to the user
  5361. rem except tables in SYS and SYSTEM ("dictionary tables").
  5362. rem 
  5363. create or replace view catalog (tname, creator, tabletype, remarks) as
  5364.   select tname, creator, tabletype, remarks
  5365.   from    syscatalog_
  5366.   where creatorid not in (0,2)
  5367. /
  5368. grant select on catalog to public with grant option;
  5369. drop synonym system.catalog;
  5370. create synonym system.catalog for catalog;
  5371.  
  5372. create or replace view tab (tname, tabtype, clusterid) as
  5373.    select o.name,
  5374.       decode(o.type, 2, 'TABLE', 3, 'CLUSTER', 
  5375.              4, 'VIEW', 5, 'SYNONYM'), t.tab#
  5376.   from  sys.tab$ t, sys.obj$ o
  5377.   where o.owner# = userenv('SCHEMAID')
  5378.   and o.type >=2
  5379.   and o.type <=5
  5380.   and o.linkname is null
  5381.   and o.obj# = t.obj# (+)
  5382. /
  5383. grant select on tab to public with grant option;
  5384. drop synonym system.tab;
  5385. create synonym system.tab for tab;
  5386. drop public synonym tab;
  5387. create public synonym tab for tab;
  5388. create or replace view col 
  5389.   (tname, colno, cname, coltype, width, scale, precision, nulls, defaultval) as
  5390.   select t.name, c.col#, c.name, 
  5391.      decode(c.type#, 1, 'VARCHAR2',
  5392.                          2, decode(c.scale, null,
  5393.                                    decode(c.precision, null, 'NUMBER', 'FLOAT'),
  5394.                                   'NUMBER'),
  5395.                          8, 'LONG', 9, 'VARCHAR',
  5396.                          12, 'DATE', 23, 'RAW', 24, 'LONG RAW',
  5397.                          69, 'ROWID',96,'CHAR', 105, 'MLSLABEL',
  5398.                          106, 'MLSLABEL', 'UNDEFINED'),
  5399.          c.length, c.scale, c.precision,
  5400.      decode(sign(c.null$),-1,'NOT NULL - DISABLED', 0, 'NULL', 
  5401.     'NOT NULL'), c.default$
  5402.   from  sys.col$ c, sys.obj$ t
  5403.   where t.obj# = c.obj#
  5404.   and   t.type in (2, 3, 4)
  5405.   and   t.owner# = userenv('SCHEMAID')
  5406. /
  5407. grant select on col to public with grant option;
  5408. drop synonym system.col;
  5409. create synonym system.col for col;
  5410. drop public synonym col;
  5411. create public synonym col for col;
  5412. create or replace view syssegobj 
  5413.     (obj#, file#, block#, type, pctfree$, pctused$) as
  5414.   select obj#, file#, block#, 'TABLE', pctfree$, pctused$ from sys.tab$
  5415.   union all
  5416.   select obj#, file#, block#, 'CLUSTER', pctfree$, pctused$ from sys.clu$
  5417.   union all
  5418.   select obj#, file#, block#, 'INDEX', to_number(null), to_number(null)
  5419.          from sys.ind$
  5420. /
  5421. grant select on syssegobj to public with grant option;
  5422. create or replace view tabquotas (tname, type, objno, nextext, maxext, pinc,
  5423.                pfree, pused) as
  5424.   select t.name, so.type, t.obj#, s.extsize, s.maxexts, s.extpct, so.pctfree$,
  5425.      so.pctused$
  5426.   from  sys.seg$ s, sys.obj$ t, syssegobj so
  5427.   where t.owner# = userenv('SCHEMAID')
  5428.   and   t.obj# = so.obj#
  5429.   and   so.file# = s.file# 
  5430.   and   so.block# = s.block#
  5431. /
  5432. grant select on tabquotas to public with grant option;
  5433. drop synonym system.tabquotas;
  5434. create synonym system.tabquotas for tabquotas;
  5435.  
  5436. create or replace view sysfiles (tsname, fname, blocks) as
  5437.   select ts.name, dbf.name, f.blocks
  5438.   from  sys.ts$ ts, sys.file$ f, sys.v$dbfile dbf
  5439.   where ts.ts# = f.ts#(+) and dbf.file# = f.file# and f.status$ = 2
  5440. /
  5441. grant select on sysfiles to public with grant option;
  5442. drop synonym system.sysfiles;
  5443. create synonym system.sysfiles for sysfiles;
  5444. create or replace view synonyms 
  5445.     (sname, syntype, creator, tname, database, tabtype) as
  5446.   select s.name, 
  5447.      decode(s.owner#,1,'PUBLIC','PRIVATE'), t.owner, t.name, 'LOCAL', 
  5448.      decode(ot.type, 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER', 4, 'VIEW',
  5449.              5, 'SYNONYM', 6, 'SEQUENCE', 7, 'PROCEDURE',
  5450.                          8, 'FUNCTION', 9, 'PACKAGE', 'UNDEFINED')
  5451.   from  sys.obj$ s, sys.obj$ ot, sys.syn$ t, sys.user$ u
  5452.   where s.obj# = t.obj# 
  5453.     and ot.linkname is null
  5454.     and s.type = 5
  5455.     and ot.name = t.name
  5456.     and t.owner = u.name
  5457.     and ot.owner# = u.user#
  5458.     and s.owner# in (1,userenv('SCHEMAID'))
  5459.     and t.node is null
  5460. union all
  5461.   select s.name, decode(s.owner#, 1, 'PUBLIC', 'PRIVATE'),
  5462.      t.owner, t.name, t.node, 'REMOTE'
  5463.   from  sys.obj$ s, sys.syn$ t
  5464.   where s.obj# = t.obj#
  5465.     and s.type = 5
  5466.     and s.owner# in (1, userenv('SCHEMAID'))
  5467.     and t.node is not null
  5468. /  
  5469. grant select on synonyms to public with grant option;
  5470. create or replace view publicsyn (sname, creator, tname, database, tabtype) as
  5471.   select sname, creator, tname, database, tabtype
  5472.   from  synonyms
  5473.   where syntype = 'PUBLIC'
  5474. /
  5475. grant select on publicsyn to public with grant option;
  5476. drop synonym system.publicsyn;
  5477. create synonym system.publicsyn for publicsyn;
  5478.  
  5479. rem 
  5480. rem V6 views required for other Oracle products
  5481. rem
  5482.  
  5483. create or replace view TABLE_PRIVILEGES
  5484.       (GRANTEE, OWNER, TABLE_NAME, GRANTOR,
  5485.        SELECT_PRIV, INSERT_PRIV, DELETE_PRIV, 
  5486.        UPDATE_PRIV, REFERENCES_PRIV, ALTER_PRIV, INDEX_PRIV,
  5487.        CREATED)
  5488. as
  5489. select ue.name, u.name, o.name, ur.name,
  5490.     decode(substr(lpad(sum(power(10, privilege#*2) + 
  5491.       decode(option$, null, 0, power(10, privilege#*2 + 1))), 26, '0'), 7, 2), 
  5492.       '00', 'N', '01', 'Y', '11', 'G', 'N'),
  5493.      decode(substr(lpad(sum(decode(col#, null, power(10, privilege#*2) + 
  5494.        decode(option$, null, 0, power(10, privilege#*2 + 1)), 0)), 26, '0'), 
  5495.               13, 2), '01', 'A', '11', 'G', 
  5496.          decode(substr(lpad(sum(decode(col#, null, 0, power(10, privilege#))),
  5497.                 12, '0'), 6, 1), '0', 'N', 'S')),
  5498.     decode(substr(lpad(sum(power(10, privilege#*2) + 
  5499.       decode(option$, null, 0, power(10, privilege#*2 + 1))), 26, '0'), 19, 2), 
  5500.       '00', 'N', '01', 'Y', '11', 'G', 'N'),
  5501.     decode(substr(lpad(sum(decode(col#, null, power(10, privilege#*2) + 
  5502.       decode(option$, null, 0, power(10, privilege#*2 + 1)), 0)), 26, '0'), 
  5503.              5, 2),'01', 'A', '11', 'G', 
  5504.           decode(substr(lpad(sum(decode(col#, null, 0, power(10, privilege#))),
  5505.                  12, '0'), 2, 1), '0', 'N', 'S')),
  5506.     decode(substr(lpad(sum(decode(col#, null, power(10, privilege#*2) + 
  5507.       decode(option$, null, 0, power(10, privilege#*2 + 1)), 0)), 26, '0'), 
  5508.              3, 2), '01', 'A', '11', 'G', 
  5509.           decode(substr(lpad(sum(decode(col#, null, 0, power(10, privilege#))),
  5510.                  12, '0'), 1, 1), '0', 'N', 'S')),
  5511.    decode(substr(lpad(sum(power(10, privilege#*2) + 
  5512.       decode(option$, null, 0, power(10, privilege#*2 + 1))), 26, '0'), 25, 2), 
  5513.       '00', 'N', '01', 'Y', '11', 'G', 'N'), 
  5514.     decode(substr(lpad(sum(power(10, privilege#*2) + 
  5515.       decode(option$, null, 0, power(10, privilege#*2 + 1))), 26, '0'), 15, 2), 
  5516.       '00', 'N', '01', 'Y', '11', 'G', 'N'), min(null)
  5517. from sys.objauth$ oa, sys.obj$ o, sys.user$ u, sys.user$ ur, sys.user$ ue
  5518. where oa.obj# = o.obj#
  5519.   and oa.grantor# = ur.user#
  5520.   and oa.grantee# = ue.user#
  5521.   and u.user# = o.owner#
  5522.   and (oa.grantor# = userenv('SCHEMAID') or
  5523.        oa.grantee# in (select kzsrorol from x$kzsro) or
  5524.        o.owner# = userenv('SCHEMAID'))
  5525.   group by u.name, o.name, ur.name, ue.name
  5526. /
  5527. comment on table TABLE_PRIVILEGES is
  5528. 'Grants on objects for which the user is the grantor, grantee, owner, 
  5529.  or an enabled role or PUBLIC is the grantee'
  5530. /
  5531. comment on column TABLE_PRIVILEGES.GRANTEE is
  5532. 'Name of the user to whom access was granted'
  5533. /
  5534. comment on column TABLE_PRIVILEGES.OWNER is
  5535. 'Owner of the object'
  5536. /
  5537. comment on column TABLE_PRIVILEGES.TABLE_NAME is
  5538. 'Name of the object'
  5539. /
  5540. comment on column TABLE_PRIVILEGES.GRANTOR is
  5541. 'Name of the user who performed the grant'
  5542. /
  5543. comment on column TABLE_PRIVILEGES.SELECT_PRIV is
  5544. 'Permission to SELECT from the object?'
  5545. /
  5546. comment on column TABLE_PRIVILEGES.INSERT_PRIV is
  5547. 'Permission to INSERT into the object?'
  5548. /
  5549. comment on column TABLE_PRIVILEGES.DELETE_PRIV is
  5550. 'Permission to DELETE from the object?'
  5551. /
  5552. comment on column TABLE_PRIVILEGES.UPDATE_PRIV is
  5553. 'Permission to UPDATE the object?'
  5554. /
  5555. comment on column TABLE_PRIVILEGES.REFERENCES_PRIV is
  5556. 'Permission to make REFERENCES to the object?'
  5557. /
  5558. comment on column TABLE_PRIVILEGES.ALTER_PRIV is
  5559. 'Permission to ALTER the object?'
  5560. /
  5561. comment on column TABLE_PRIVILEGES.INDEX_PRIV is
  5562. 'Permission to create/drop an INDEX on the object?'
  5563. /
  5564. comment on column TABLE_PRIVILEGES.CREATED is
  5565. 'Timestamp for the grant'
  5566. /
  5567. drop public synonym TABLE_PRIVILEGES
  5568. /
  5569. create public synonym TABLE_PRIVILEGES for TABLE_PRIVILEGES
  5570. /
  5571. grant select on TABLE_PRIVILEGES to PUBLIC
  5572. /
  5573. create or replace view COLUMN_PRIVILEGES
  5574.       (GRANTEE, OWNER, TABLE_NAME, COLUMN_NAME, GRANTOR,
  5575.        INSERT_PRIV, UPDATE_PRIV, REFERENCES_PRIV,
  5576.        CREATED)
  5577. as
  5578. select ue.name, u.name, o.name, c.name, ur.name,
  5579.     decode(substr(lpad(sum(power(10, privilege#*2) + 
  5580.       decode(option$, null, 0, power(10, privilege#*2 + 1))), 26, '0'), 13, 2), 
  5581.       '00', 'N', '01', 'Y', '11', 'G', 'N'),
  5582.     decode(substr(lpad(sum(power(10, privilege#*2) + 
  5583.       decode(option$, null, 0, power(10, privilege#*2 + 1))), 26, '0'), 5, 2), 
  5584.       '00', 'N', '01', 'Y', '11', 'G', 'N'),
  5585.     decode(substr(lpad(sum(power(10, privilege#*2) + 
  5586.       decode(option$, null, 0, power(10, privilege#*2 + 1))), 26, '0'), 3, 2), 
  5587.       '00', 'N', '01', 'Y', '11', 'G', 'N'), min(null)
  5588. from sys.objauth$ oa, sys.col$ c,sys.obj$ o, sys.user$ u, sys.user$ ur, 
  5589.      sys.user$ ue
  5590. where oa.col# is not null
  5591.   and oa.obj# = c.obj#
  5592.   and oa.col# = c.col#
  5593.   and oa.obj# = o.obj#
  5594.   and oa.grantor# = ur.user#
  5595.   and oa.grantee# = ue.user#
  5596.   and u.user# = o.owner#
  5597.   and (oa.grantor# = userenv('SCHEMAID') or
  5598.        oa.grantee# in (select kzsrorol from x$kzsro) or
  5599.        o.owner# = userenv('SCHEMAID'))
  5600.   group by u.name, o.name, c.name, ur.name, ue.name
  5601. /
  5602. comment on table COLUMN_PRIVILEGES is
  5603. 'Grants on columns for which the user is the grantor, grantee, owner, or 
  5604.  an enabled role or PUBLIC is the grantee'
  5605. /
  5606. comment on column COLUMN_PRIVILEGES.GRANTEE is
  5607. 'Name of the user to whom access was granted'
  5608. /
  5609. comment on column COLUMN_PRIVILEGES.OWNER is
  5610. 'Username of the owner of the object'
  5611. /
  5612. comment on column COLUMN_PRIVILEGES.TABLE_NAME is
  5613. 'Name of the object'               
  5614. /
  5615. comment on column COLUMN_PRIVILEGES.COLUMN_NAME is
  5616. 'Name of the column'
  5617. /
  5618. comment on column COLUMN_PRIVILEGES.GRANTOR is
  5619. 'Name of the user who performed the grant'
  5620. /
  5621. comment on column COLUMN_PRIVILEGES.INSERT_PRIV is
  5622. 'Permission to INSERT into the column?'
  5623. /
  5624. comment on column COLUMN_PRIVILEGES.UPDATE_PRIV is
  5625. 'Permission to UPDATE the column?'
  5626. /
  5627. comment on column COLUMN_PRIVILEGES.REFERENCES_PRIV is
  5628. 'Permission to make REFERENCES to the column?'
  5629. /
  5630. comment on column COLUMN_PRIVILEGES.CREATED is
  5631. 'Timestamp for the grant'
  5632. /
  5633. drop public synonym COLUMN_PRIVILEGES
  5634. /
  5635. create public synonym COLUMN_PRIVILEGES for COLUMN_PRIVILEGES
  5636. /
  5637. grant select on COLUMN_PRIVILEGES to PUBLIC
  5638. /
  5639.  
  5640. rem    **********************************************************************
  5641. rem        DBA TWO PHASE COMMIT DECISION / DAMAGE ASSESSMENT TABLES
  5642. rem    **********************************************************************
  5643. rem     PSS1$: used to add user name column to pending_sub_sessions$
  5644. create or replace view pss1$ as
  5645. select    pss.*, u.name owner_name
  5646. from     sys.pending_sub_sessions$ pss, sys.user$ u
  5647. where   pss.link_owner = u.user#;
  5648.  
  5649. rem     PS1$: used to add user name column to pending_sessions$
  5650. create or replace view ps1$ as
  5651. select    ps.*, u.name db_user
  5652. from     sys.pending_sessions$ ps, sys.user$ u
  5653. where   ps.db_userid = u.user#;
  5654.  
  5655. rem     DBA_2PC_PENDING
  5656. rem    use this view to find info about pending (i.e. incomplete) distributed
  5657. rem    transactions at this DB.  Use os_user and db_userid to help track down
  5658. rem    a responsible party.  Use DBA_2PC_NEIGHBORS to find the commit point.
  5659. rem    Or take the advice, if offered.
  5660.  
  5661. create or replace view DBA_2PC_PENDING
  5662.     (local_tran_id, global_tran_id, state, mixed,
  5663.      advice, tran_comment, fail_time, force_time,
  5664.      retry_time, os_user, os_terminal, host, db_user, commit#) as
  5665. select  local_tran_id,
  5666.         nvl(global_oracle_id, global_tran_fmt||'.'||global_foreign_id),
  5667.     state, decode(status,'D','yes','no'), heuristic_dflt, tran_comment,
  5668.         fail_time, heuristic_time, reco_time,
  5669.         top_os_user, top_os_terminal, top_os_host, top_db_user, global_commit#
  5670. from    sys.pending_trans$;
  5671.  
  5672. comment on table DBA_2PC_PENDING is
  5673.   'info about distributed transactions awaiting recovery';
  5674. comment on column DBA_2PC_PENDING.local_tran_id is
  5675.   'string of form: n.n.n, n a number';
  5676. comment on column DBA_2PC_PENDING.global_tran_id is
  5677.   'globally unique transaction id';
  5678. comment on column DBA_2PC_PENDING.state is
  5679.   'collecting, prepared, committed, forced commit, or forced rollback';
  5680. comment on column DBA_2PC_PENDING.mixed is
  5681.   'yes => part of the transaction committed and part rolled back (commit or rollback with the FORCE option was used)';
  5682. comment on column DBA_2PC_PENDING.advice is
  5683.   'C for commit, R for rollback, else null';
  5684. comment on column DBA_2PC_PENDING.tran_comment is
  5685.   'text for "commit work comment <text>"';
  5686. comment on column DBA_2PC_PENDING.fail_time is
  5687.   'value of SYSDATE when the row was inserted (tx or system recovery)';
  5688. comment on column DBA_2PC_PENDING.force_time is
  5689.  'time of manual force decision (null if not forced locally)';
  5690. comment on column DBA_2PC_PENDING.retry_time is
  5691.  'time automatic recovery (RECO) last tried to recover the transaction';
  5692. comment on column DBA_2PC_PENDING.os_user is
  5693.   'operating system specific name for the end-user';
  5694. comment on column DBA_2PC_PENDING.os_terminal is
  5695.   'operating system specific name for the end-user terminal';
  5696. comment on column DBA_2PC_PENDING.host is
  5697.   'name of the host machine for the end-user';
  5698. comment on column DBA_2PC_PENDING.db_user is
  5699.   'Oracle user name of the end-user at the topmost database';
  5700. comment on column DBA_2PC_PENDING.commit# is
  5701.   'global commit number for committed transactions';
  5702.  
  5703. rem    DBA_2PC_NEIGHBORS: use this view to obtain info about incoming and
  5704. rem      outgoing connections for a particular transaction.  It is suggested
  5705. rem       that it be queried using:
  5706. rem        select * from dba_2pc_neighbors where local_tran_id = <id>
  5707. rem         order by sess#, "IN_OUT";
  5708. rem      This will group sessions, with outgoing connections following the
  5709. rem      incoming connection for each session.
  5710. rem   columns:
  5711. rem    IN_OUT: 'in' for incoming connections, 'out' for outgoing
  5712. rem     DATABASE: if 'in', the name of the client database, else name of 
  5713. rem      outgoing db link
  5714. rem    DBUSER_OWNER: if 'in', name of local user, else owner of db link
  5715. rem    INTERFACE: 'C' hold commit, else 'N'.  For incoming links, 'C'
  5716. rem       means that we or a DB at the other end of one of our outgoing links
  5717. rem       is the commit point (and must not forget until told by the client).
  5718. rem      For outgoing links, 'C' means that the child at the other end is the
  5719. rem      commit point, and will know whether the tran should commit or abort.
  5720. rem      If we are indoubt and do not find a 'C' on an outgoing link, then
  5721. rem      the top level user/DB, or the client, should be able to locate the
  5722. rem      commit point.
  5723. rem    DBID: the database id at the other end of the connection
  5724. rem    SESS#: session number at this database of the connection.  Sessions are
  5725. rem       numbered consecutively from 1; there is always at least 1 session, 
  5726. rem      and exactly 1 incoming connection per session.
  5727. rem    BRANCH_ID: transaction branch.  An incoming branch is a two byte
  5728. rem      hexadecimal number.  The first byte is the session_id of the
  5729. rem      remote parent session.  The second byte is the branch_id of the
  5730. rem      remote parent session.  If the remote parent session is not Oracle,
  5731. rem      the branch_id can be up to 64 bytes.
  5732.  
  5733. create or replace view DBA_2PC_NEIGHBORS(local_tran_id, in_out, database,
  5734.                                dbuser_owner, interface, dbid, 
  5735.                    sess#, branch) as
  5736. select  local_tran_id, 'in', parent_db, db_user, interface, parent_dbid,
  5737.         session_id, rawtohex(branch_id)
  5738. from    sys.ps1$
  5739. union all
  5740. select  local_tran_id, 'out', dblink, owner_name, interface, dbid, 
  5741.         session_id, to_char(sub_session_id)
  5742. from    sys.pss1$;
  5743.  
  5744. comment on table DBA_2PC_NEIGHBORS is
  5745.   'information about incoming and outgoing connections for pending transactions';
  5746. comment on column DBA_2PC_NEIGHBORS.in_out is
  5747.   '"in" for incoming connections, "out" for outgoing';
  5748. comment on column DBA_2PC_NEIGHBORS.database is
  5749.   'in: client database name; out: outgoing db link';
  5750. comment on column DBA_2PC_NEIGHBORS.dbuser_owner is
  5751.   'in: name of local user; out: owner of db link';
  5752. comment on column DBA_2PC_NEIGHBORS.interface is
  5753.   '"C" for request commit, else "N" for prepare or request readonly commit';
  5754. comment on column DBA_2PC_NEIGHBORS.dbid is
  5755.   'the database id at the other end of the connection';
  5756. comment on column DBA_2PC_NEIGHBORS.sess# is
  5757.   'session number at this database of the connection';
  5758. comment on column DBA_2PC_NEIGHBORS.branch is
  5759.   'transaction branch ID at this database of the connection';
  5760. /
  5761.  
  5762. Rem    GLOBAL DATABASE NAME
  5763.  
  5764. create or replace view GLOBAL_NAME ( GLOBAL_NAME ) as
  5765.        select value$ from sys.props$ where name = 'GLOBAL_DB_NAME'
  5766. /
  5767. comment on table GLOBAL_NAME is 'global database name'
  5768. /
  5769. comment on column GLOBAL_NAME.GLOBAL_NAME is 'global database name'
  5770. /
  5771. grant select on GLOBAL_NAME to public with grant option
  5772. /
  5773. drop public synonym GLOBAL_NAME
  5774. /
  5775. create public synonym GLOBAL_NAME for GLOBAL_NAME
  5776. /
  5777.  
  5778. Rem     PRODUCT COMPONENT VERSION
  5779. create or replace view product_component_version(product,version,status) as
  5780. (select
  5781. substr(banner,1, instr(banner,'Version')-1),
  5782. substr(banner, instr(banner,'Version')+8,
  5783. instr(banner,' - ')-(instr(banner,'Version')+8)),
  5784. substr(banner,instr(banner,' - ')+3)
  5785. from v$version
  5786. where instr(banner,'Version') > 0
  5787. and
  5788. ((instr(banner,'Version') <   instr(banner,'Release')) or
  5789. instr(banner,'Release') = 0))
  5790. union
  5791. (select
  5792. substr(banner,1, instr(banner,'Release')-1),
  5793. substr(banner, instr(banner,'Release')+8,
  5794. instr(banner,' - ')-(instr(banner,'Release')+8)),
  5795. substr(banner,instr(banner,' - ')+3)
  5796. from v$version
  5797. where instr(banner,'Release') > 0
  5798. and
  5799. instr(banner,'Release') <   instr(banner,' - '))
  5800. /
  5801. comment on table product_component_version is 
  5802. 'version and status information for component products'
  5803. /
  5804. comment on column product_component_version.product is 
  5805. 'product name';
  5806. /
  5807. comment on column product_component_version.version is 
  5808. 'version number'
  5809. /
  5810. comment on column product_component_version.status is 
  5811. 'status of release'
  5812. /
  5813. grant select on product_component_version to public with grant option
  5814. /
  5815. drop public synonym product_component_version
  5816. /
  5817. create public synonym product_component_version for product_component_version
  5818. /
  5819.  
  5820. Rem Auditing views
  5821. @@cataudit
  5822.  
  5823. Rem Import/export views
  5824. @@catexp
  5825.  
  5826. Rem Loader views
  5827. @@catldr
  5828.  
  5829. Rem Server Manager views
  5830. @@catsvrmg
  5831.  
  5832. Rem ---------------------------------------------------------------------------
  5833. Rem THIS IS THE END OF THIS FILE - IF I AM NOT HERE THEN RCS HAS TRUNCATED FILE
  5834. Rem ---------------------------------------------------------------------------
  5835.