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

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