home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 February / PCWK0296.iso / po7_win / db / rdbms71 / catexp.sql < prev    next >
Encoding:
Text File  |  1994-08-10  |  41.5 KB  |  1,033 lines

  1. rem 
  2. rem $Header: catexp.sql 7010400.2 94/07/21 22:29:17 cli Generic<base> $ expvew.sql 
  3. rem 
  4. Rem Copyright (c) 1987 by Oracle Corporation
  5. Rem NAME
  6. REM    CATEXP.SQL - CATalog EXPort sql script
  7. Rem  FUNCTION
  8. Rem    Creates internal views for Export/Import utility
  9. Rem  NOTES
  10. Rem    Must be run when connected to SYS or INTERNAL.
  11. Rem  MODIFIED
  12. Rem     vraghuna   05/16/94 -  bug 215597 - change exu7snaplu also
  13. Rem     vraghuna   05/12/94 -  bug 215597 - change exu7snapl to exclude slog
  14. Rem     vraghuna   02/09/94 -  add exu7ver for version control
  15. Rem     vraghuna   02/02/94 -  bug 190236 - add outer join to exu7ord in exu7ve
  16. Rem     vraghuna   01/17/94 -  bug 191751 - add support for deferred RPC/RepCat
  17. Rem     vraghuna   01/12/94 -  bug 191750 - add support for refresh groups
  18. Rem     vraghuna   01/11/94 -  bug 191749 - add support for job queues exu7jbq
  19. Rem     vraghuna   01/11/94 -  bug 193733 - use basename in incr trigger views
  20. Rem     vraghuna   01/11/94 -  bug 193732 - fix exu7del for trigs, pkg bodies
  21. Rem     vraghuna   01/10/94 -  bug 192781 - add basetable name for trigger view
  22. Rem     vraghuna   12/30/93 -  bug 192652 - change MM to MI for exu7spr
  23. Rem     vraghuna   12/07/93 -  bug 186073 - add read only tablespaces
  24. Rem     vraghuna   08/18/93 -  bug 174029 - moving role creation to sql.bsq
  25. Rem     vraghuna   07/07/93 -  add support for updatable snapshots
  26. Rem     vraghuna   06/17/93 -  bug 166480 - add exu7erc for resource costs
  27. Rem     vraghuna   06/17/93 -  bug 168261 - imp_full_database needs insert priv
  28. Rem     vraghuna   06/17/93 -  bug 166482 - export role passwords
  29. Rem     vraghuna   05/27/93 -  bug 166484 - add audt to exu7spr
  30. Rem     ltung      05/16/93 -  export parallel/cache parameters 
  31. Rem     vraghuna   03/15/93 -  bug 140485 - incrementals on tables with constra
  32. Rem     vraghuna   03/12/93 -  bug 152906 - add tspname to exu7uscu 
  33. Rem     vraghuna   01/27/93 -  bug 146283 - add exu7usc 
  34. Rem     vraghuna   12/18/92 -  bug 143375 - break up exu7col 
  35. Rem     vraghuna   12/02/92 -  bug 139302 - speed up exu7colnn 
  36. Rem     tpystyne   11/07/92 -  use create or replace view 
  37. Rem     vraghuna   10/28/92 -  bug 130560 - add exu7ful 
  38. Rem     vraghuna   10/23/92 -  bug 135594 - remove exu7inv and exu7invu 
  39. Rem     glumpkin   10/20/92 -  Renamed from EXPVEW.SQL 
  40. Rem     vraghuna   10/14/92 -  bug 131957 - add field to exu7sto and exu7stou 
  41. Rem     vraghuna   07/14/92 -  bug 115048 - support for analyze statement 
  42. Rem     cheigham   06/24/92 -  add exu7colnn view 
  43. Rem     cheigham   06/22/92 -  fix cdef$,col$ joins to accommodate changes for 
  44. Rem     jbellemo   06/12/92 -  add mapping for MLSLABEL 
  45. Rem     vraghuna   06/03/92 -  bug 39511 - add exu7grs 
  46. Rem     cheigham   05/27/92 -  speed up exu7vew 
  47. Rem     cheigham   02/13/92 -  add select any to imp_full_database 
  48. Rem     cheigham   02/13/92 -  grant alter any table to imp_full_database 
  49. Rem     cheigham   01/29/92 -  export altered clusters in inc. exports 
  50. Rem     cheigham   01/09/92 -  add more privs to imp_full_database 
  51. Rem     cheigham   11/15/91 -  fix object codes 
  52. Rem     cheigham   11/06/91 -  fix inc. trigger views 
  53. Rem     cheigham   11/02/91 -  merge in hash changes 
  54. Rem     cheigham   10/11/91 -  view names: exu -> exu7
  55. Rem     cheigham   09/27/91 -  add snapshot views 
  56. Rem     sksingh    09/30/91 -  merge changes from branch 1.13.50.1 
  57. Rem     sksingh    09/23/91 -  replace spare1,2,3 with match, refact, enabled
  58. Rem     agupta     09/20/91 -  add support for lists/groups storage params 
  59. Rem     agupta     08/16/91 -  enable|disable constraints 
  60. Rem     agupta     07/30/91 -  7037 - views not created in dependency or
  61. Rem     agupta     07/02/91 -  timestamp syntax for procedures 
  62. Rem     agupta     06/21/91 -  fix errors in exurlg 
  63. Rem     agupta     06/14/91 -  user$ column name changes 
  64. Rem     agupta     05/31/91 -  add userid to tablespace quota view 
  65. Rem     agupta     05/04/91 -  fix unique constraints bug 
  66. Rem     agupta     04/16/91 -  fix auditing views 
  67. Rem     jwijaya    04/12/91 -  remove LINKNAME IS NULL 
  68. Rem     rkooi      04/01/91 -  add 'o.linkname IS NULL' clause 
  69. Rem     Gupta      02/26/90 -  Lots of modifications for V7
  70. Rem     Hong       10/31/88 -  don't export quotas of 0
  71. Rem     Hong       09/21/88 -  allow null precision/scale
  72. Rem     Hong       09/10/88 -  fix outer joins
  73. Rem     Hong       08/10/88 -  get default/temp tablespace in exuusr
  74. Rem     Hong       07/01/88 -  get obj id in some views
  75. Rem     Hong       06/10/88 -  remove userid != 0 from views
  76. Rem     Hong       04/28/88 -  comment$ moved to com$
  77. Rem     Hong       03/24/88 -  add audit field to exu7seq
  78. Rem     Hong       03/07/88 -  deal with initrans, maxtrans
  79. Rem                            add views for constraints, sequence #
  80. Rem     Hong       02/01/88 -  add exuico and exuicou
  81. Rem                            temporary commented out col$.default$
  82. Rem     Hong       02/01/88 -  fix exufil to use v$dbfile directly
  83. Rem     Hong       12/12/87 -  fix exutbs
  84. Rem     Hong       12/07/87 -  handle min extents 
  85. Rem
  86.  
  87. set echo on;
  88.  
  89. rem this role allows the grantee to perform full database exports
  90. rem including incremental exports
  91. grant select any table to exp_full_database;
  92. grant backup any table to exp_full_database;
  93. GRANT insert,update,delete
  94.  ON sys.incexp
  95.  TO exp_full_database;
  96. GRANT insert,update,delete
  97.  ON sys.incvid
  98.  TO exp_full_database;
  99. GRANT insert,update,delete
  100.  ON sys.incfil
  101.  TO exp_full_database;
  102. grant exp_full_database to dba;
  103.  
  104. rem this role allows the grantee to perform full database imports
  105. grant become user to imp_full_database;
  106. grant create any cluster to imp_full_database;
  107. grant create any index to imp_full_database;
  108. grant create any table to imp_full_database;
  109. grant create any procedure to imp_full_database;
  110. grant create any sequence to imp_full_database;
  111. grant create any snapshot to imp_full_database;
  112. grant create any synonym to imp_full_database;
  113. grant create any trigger to imp_full_database;
  114. grant create any view to imp_full_database;
  115. grant create profile to imp_full_database;
  116. grant create public database link to imp_full_database;
  117. grant create database link to imp_full_database;
  118. grant create public synonym to imp_full_database;
  119. grant create rollback segment to imp_full_database;
  120. grant create role to imp_full_database;
  121. grant create tablespace to imp_full_database;
  122. grant create user to imp_full_database;
  123. grant audit any to imp_full_database;
  124. grant comment any table to imp_full_database;
  125. grant alter any table to imp_full_database;
  126. grant select any table to imp_full_database;
  127. grant execute any procedure to imp_full_database;
  128. grant insert any table to imp_full_database;
  129.  
  130. rem for import of incremental export files
  131. grant drop any cluster to imp_full_database;
  132. grant drop any index to imp_full_database;
  133. grant drop any table to imp_full_database;
  134. grant drop any procedure to imp_full_database;
  135. grant drop any sequence to imp_full_database;
  136. grant drop any snapshot to imp_full_database;
  137. grant drop any synonym to imp_full_database;
  138. grant drop any trigger to imp_full_database;
  139. grant drop any view to imp_full_database;
  140. grant drop profile to imp_full_database;
  141. grant drop public database link to imp_full_database;
  142. grant drop public synonym to imp_full_database;
  143. grant drop rollback segment to imp_full_database;
  144. grant drop any role to imp_full_database;
  145. grant drop tablespace to imp_full_database;
  146. grant drop user to imp_full_database;
  147.  
  148. grant imp_full_database to dba;
  149.  
  150. rem all tables
  151. CREATE OR REPLACE view exu7tab 
  152.                    (objid,name, owner, ownerid, tablespace, fileno, blockno,
  153.             audit$, comment$, clusterflag, mtime, modified, pctfree$,
  154.                     pctused$, initrans, maxtrans, parallel, cache) AS
  155.        SELECT o$.obj#,o$.name, u$.name, o$.owner#, ts$.name, t$.file#, 
  156.           t$.block#, t$.audit$, c$.comment$, NVL(t$.clu#, 0), o$.mtime,
  157.           t$.modified, t$.pctfree$, t$.pctused$, t$.initrans, t$.maxtrans,
  158.               NVL(t$.spare1,0), NVL(t$.spare2,0)
  159.        FROM sys.tab$ t$, sys.obj$ o$, sys.ts$ ts$, sys.user$ u$, sys.com$ c$
  160.        WHERE  t$.obj# = o$.obj# and t$.ts# = ts$.ts# and 
  161.               u$.user# = o$.owner# and o$.obj# = c$.obj#(+) 
  162.           and c$.col#(+) is null
  163. /
  164. rem tables for incremental export: modified, altered or new
  165. CREATE OR REPLACE view exu7tabi AS 
  166.        SELECT t.* from exu7tab t,incexp i, incvid v
  167.        WHERE t.name  = i.name(+) AND t.ownerid = i.owner#(+) AND
  168.              NVL(i.type,2) = 2 AND  
  169.              (t.modified = 1 OR t.mtime > i.itime OR 
  170.               NVL(i.expid,9999) > v.expid)
  171. /         
  172. rem tables for cumulative export: modified, last export was inc, altered or new
  173. CREATE OR REPLACE view exu7tabc AS 
  174.        SELECT t.* from exu7tab t,incexp i, incvid v
  175.        WHERE  t.name  = i.name(+) AND t.ownerid = i.owner#(+) AND 
  176.              NVL(i.type,2) = 2 AND 
  177.               (t.modified = 1 OR i.itime > NVL(i.ctime,
  178.                                              TO_DATE('01-01-00','DD-MM-YY'))
  179.                OR t.mtime > i.itime OR NVL(i.expid,9999) > v.expid)
  180. /
  181. rem current user's tables 
  182. CREATE OR REPLACE view exu7tabu AS
  183.        SELECT * from exu7tab WHERE ownerid = uid
  184. /
  185. grant select on exu7tabu to public;
  186.  
  187. rem not null constraints on columns
  188. CREATE OR REPLACE view exu7colnn (tobjid, colid, conname, isnull, enabled) AS
  189.       SELECT cc$.obj#, cc$.col#, 
  190.               DECODE(SUBSTR(con$.name,1,5), 'SYS_C', '', NVL(con$.name, '')),
  191.           1, NVL(cd$.enabled, 0)
  192.       FROM  sys.con$ con$, sys.cdef$ cd$, sys.ccol$ cc$
  193.       WHERE cc$.con# = cd$.con# and
  194.             cd$.con# = con$.con# and cd$.type =7
  195. /
  196. CREATE OR REPLACE view exu7col_temp
  197.                    (tobjid, towner, townerid, tname, name, length, precision, 
  198.             scale, type, isnull, conname, colid, comment$, --default$, 
  199.                 dfltlen, enabled) AS
  200.        SELECT o$.obj#, u$.name, o$.owner#, o$.name, c$.name, c$.length, 
  201.               c$.precision, c$.scale, c$.type#, NVL(cn.isnull,0), 
  202.               cn.conname, c$.col#, com$.comment$,-- c$.default$, 
  203.           NVL(c$.deflength, 0), cn.enabled
  204.        FROM sys.col$ c$, sys.obj$ o$, sys.user$ u$, sys.com$ com$,
  205.         sys.exu7colnn cn
  206.        WHERE c$.obj# = o$.obj# and o$.owner# = u$.user# and 
  207.          c$.obj# = com$.obj#(+) and c$.col# = com$.col#(+) and
  208.          c$.obj# = cn.tobjid and c$.col# = cn.colid
  209.   union all
  210.        SELECT o$.obj#, u$.name, o$.owner#, o$.name, c$.name, c$.length, 
  211.               c$.precision, c$.scale, c$.type#, 0,
  212.               null, c$.col#, com$.comment$,-- c$.default$, 
  213.           NVL(c$.deflength, 0), to_number(null)
  214.        FROM sys.col$ c$, sys.obj$ o$, sys.user$ u$, sys.com$ com$
  215.        WHERE c$.obj# = o$.obj# and o$.owner# = u$.user# and 
  216.          c$.obj# = com$.obj#(+) and c$.col# = com$.col#(+)
  217.              and not exists 
  218.               (select null from sys.exu7colnn cn
  219.              where c$.obj# = cn.tobjid and c$.col# = cn.colid)
  220. /
  221. create or replace view exu7col
  222.    (tobjid, towner, townerid, tname, name, length, precision,
  223.     scale, type, isnull, conname, colid, comment$, default$,
  224.     dfltlen, enabled) AS
  225.  select tobjid, towner, townerid, v$.tname, v$.name, v$.length, v$.precision,
  226.                     v$.scale, type, isnull, conname, colid, comment$, default$,
  227.                     dfltlen, enabled
  228.    from exu7col_temp v$, sys.col$ c$
  229.     where c$.obj# = v$.tobjid and c$.col# = v$.colid
  230. /
  231.  
  232. CREATE OR REPLACE view exu7colu AS                 /* current user's columns */
  233.        SELECT * from exu7col WHERE townerid = uid
  234. /
  235. grant select on exu7colu to public;
  236.  
  237. rem all columns for index
  238. CREATE OR REPLACE view exu7ico 
  239.                    (tobjid, towner, townerid, tname, name, length, precision,
  240.             scale, type, isnull, conname, colid, comment$, default$, 
  241.             dfltlen, enabled) AS
  242.        SELECT o$.obj#, u$.name, o$.owner#, o$.name, c$.name, 0, 0, 0, 0, 0, '',
  243.               i$.pos#, NULL, NULL, 0, 0
  244.        FROM sys.col$ c$, sys.icol$ i$, sys.obj$ o$, sys.user$ u$
  245.        WHERE c$.obj# = i$.bo# and c$.col# = i$.col# and 
  246.          i$.obj# = o$.obj# and o$.owner# = u$.user#
  247. /
  248. CREATE OR REPLACE view exu7icou AS           /* current user's columns */
  249.        SELECT * from exu7ico WHERE townerid = uid
  250. /
  251. grant select on exu7icou to public;
  252.  
  253. rem all users
  254. CREATE OR REPLACE view exu7usr 
  255.                    (name, userid, passwd, defrole, datats, tempts, profile#, 
  256.                 profname) AS 
  257.        SELECT u.name, u.user#, DECODE(u.password, 'N', '', u.password), 
  258.               DECODE(u.defrole, 0, 'N', 1, 'A', 'L'), ts1.name, ts2.name,
  259.           u.resource$, p.name
  260.        FROM sys.user$ u, sys.ts$ ts1, sys.ts$ ts2, sys.profname$ p
  261.        WHERE u.datats# = ts1.ts# and u.tempts# = ts2.ts# and u.type = 1 and
  262.              u.resource$ = p.profile#
  263. /
  264. CREATE OR REPLACE view exu7usru AS                 /* current user */
  265.        SELECT * from exu7usr WHERE userid = UID
  266. /
  267. grant select on exu7usru to public;
  268.  
  269. rem all users' default roles
  270. CREATE OR REPLACE view exu7dfr (name, userid, role, roleid) AS
  271.        SELECT u$.name, u$.user#, u1$.name, u1$.user#
  272.        FROM sys.user$ u$, sys.user$ u1$, sys.defrole$ d$
  273.        WHERE u$.user# = d$.user# and u1$.user# = d$.role#
  274. /
  275. rem all roles
  276. CREATE OR REPLACE view exu7rol (role, password) AS    /* enumerate all roles */
  277.        SELECT name, password
  278.        FROM sys.user$ 
  279.        WHERE type = 0 and name not in 
  280.             ('CONNECT', 'RESOURCE', 'DBA', 'PUBLIC', '_NEXT_USER', 
  281.          'EXP_FULL_DATABASE', 'IMP_FULL_DATABASE')
  282. /
  283. rem all role grants
  284. CREATE OR REPLACE view exu7rlg
  285.                    (grantee, granteeid, role, roleid, admin, sequence) AS
  286.     SELECT u1$.name, u1$.user#, u2$.name, u2$.user#, 
  287.            NVL(g$.option$, 0), g$.sequence#
  288.        FROM sys.user$ u1$, sys.user$ u2$, sys.sysauth$ g$ 
  289.     WHERE u1$.user# = g$.grantee# AND u2$.user# = g$.privilege# AND 
  290.           g$.privilege# > 0
  291. /
  292. rem all system privs, type is 1 for user, 0 for role
  293. CREATE OR REPLACE view exu7spv (grantee, granteeid, priv, wgo, sequence) AS
  294.        SELECT u1$.name, u1$.user#, m$.name, NVL(a$.option$,0), a$.sequence#
  295.        FROM sys.sysauth$ a$, sys.system_privilege_map m$, sys.user$ u1$
  296.        WHERE a$.grantee# = u1$.user# and a$.privilege# = m$.privilege AND 
  297.          u1$.name not in 
  298.          ('CONNECT', 'RESOURCE', 'DBA', 'PUBLIC', '_NEXT_USER', 
  299.          'EXP_FULL_DATABASE', 'IMP_FULL_DATABASE')
  300. /
  301. rem all grants
  302. CREATE OR REPLACE view exu7grn (objid, grantor, grantorid, grantee, priv, wgo,
  303.                     creatorid, sequence) AS
  304.        SELECT t$.obj#, ur$.name, t$.grantor#, ue$.name, 
  305.               m$.name, NVL(t$.option$,0), o$.owner#, t$.sequence#
  306.        FROM sys.objauth$ t$, sys.obj$ o$, sys.user$ ur$,
  307.             sys.table_privilege_map m$, sys.user$ ue$
  308.        WHERE o$.obj# = t$.obj# AND t$.privilege# = m$.privilege AND
  309.              t$.col# IS NULL AND t$.grantor# = ur$.user# AND
  310.              t$.grantee# = ue$.user#
  311. /
  312.  
  313. rem just SYS's grants
  314. CREATE OR REPLACE view exu7grs (objid, name) AS
  315.        SELECT t$.obj#, o$.name
  316.        FROM sys.objauth$ t$, sys.obj$ o$
  317.        WHERE o$.obj# = t$.obj# 
  318.     AND t$.col# is null
  319.     AND t$.grantor# = 0
  320. /
  321.  
  322. rem first level grants
  323. CREATE OR REPLACE view exu7grnu AS
  324.        SELECT * from exu7grn WHERE grantorid = UID AND creatorid = UID
  325. /
  326. grant select on exu7grnu to public;
  327.  
  328. rem all column grants
  329. CREATE OR REPLACE view exu7cgr 
  330.                    (objid, grantor, grantorid, grantee, creatorid, cname, 
  331.                 priv, sequence, wgo) AS
  332.        SELECT c$.obj#, ur$.name, c$.grantor#, ue$.name, o$.owner#, cl$.name,
  333.               m$.name, c$.sequence#, NVL(c$.option$,0)
  334.        FROM sys.objauth$ c$, sys.obj$ o$, sys.user$ ur$, sys.user$ ue$,
  335.             sys.table_privilege_map m$, sys.col$ cl$
  336.        WHERE c$.grantor# = ur$.user# AND c$.grantee# = ue$.user# AND
  337.              c$.obj# = o$.obj# AND c$.privilege# = m$.privilege AND 
  338.              c$.obj# = cl$.obj# AND c$.col# = cl$.col#
  339. /
  340. rem first level grants
  341. CREATE OR REPLACE view exu7cgru AS
  342.        SELECT * from exu7cgr WHERE grantorid = UID AND creatorid = UID
  343. /
  344. grant select on exu7cgru to public;
  345.  
  346. rem all indexes
  347. CREATE OR REPLACE view exu7ind 
  348.                    (iobjid, iname, iowner, iownerid, ispace, ifileno, iblockno,
  349.             btname, btobjid, btowner, btownerid, unique$,
  350.             cluster$, pctfree$, initrans, maxtrans, blevel)  AS
  351.        SELECT i$.obj#, i$.name, ui$.name, i$.owner#, ts$.name, ind$.file#,
  352.           ind$.block#, t$.name, t$.obj#, ut$.name, t$.owner#,
  353.               ind$.unique$, DECODE(t$.type, 3, 1, 0), ind$.pctfree$, 
  354.           ind$.initrans, ind$.maxtrans, NVL(ind$.blevel,-1)
  355.        FROM  sys.obj$ t$, sys.obj$ i$, sys.ind$ ind$,
  356.          sys.user$ ui$, sys.user$ ut$, sys.ts$ ts$
  357.        WHERE ind$.bo# = t$.obj# AND ind$.obj# = i$.obj# AND
  358.          ts$.ts# = ind$.ts# AND i$.owner# = ui$.user# AND
  359.              t$.owner# = ut$.user# AND (unique$=0 OR 
  360.          NOT EXISTS (SELECT * from sys.con$ c$
  361.              WHERE c$.owner# = i$.owner#
  362.                          AND   c$.name = i$.name))
  363. /
  364. rem current user indexes
  365. CREATE OR REPLACE view exu7indu AS
  366.        SELECT * from exu7ind WHERE iownerid = UID and btownerid = UID
  367. /
  368. grant select on exu7indu to public;
  369. rem dependency order
  370. CREATE OR REPLACE view exu7ord (dlevel, obj#) AS
  371.        SELECT MAX(LEVEL), d_obj# from sys.dependency$
  372.        CONNECT BY PRIOR d_obj# = p_obj#
  373.        GROUP BY d_obj#
  374. /
  375. grant select on exu7ord to public;
  376. rem all views 
  377. CREATE OR REPLACE view exu7vew (vobjid,vname, vlen, vtext, vowner, vownerid,
  378.             vaudit, vcomment, vcname, vlevel) AS
  379.        SELECT
  380.     o$.obj#, o$.name, v$.textlength, v$.text, u$.name, o$.owner#, 
  381.             v$.audit$, com$.comment$, 
  382.           DECODE(SUBSTR(c$.name,1,5), 'SYS_C', '', NVL(c$.name, '')),
  383.           d$.dlevel
  384.        FROM sys.obj$ o$, sys.view$ v$, sys.user$ u$, sys.cdef$ cd$,
  385.             sys.con$ c$, sys.com$ com$, exu7ord d$
  386.        WHERE v$.obj# = o$.obj# AND o$.owner# = u$.user# AND
  387.          o$.obj# = cd$.obj#(+) AND cd$.con# = c$.con#(+) AND 
  388.              o$.obj# = com$.obj#(+) AND com$.col#(+) IS NULL AND
  389.          o$.obj# = d$.obj#(+)
  390. /
  391. rem views for incremental export: new or last export not valid
  392. rem cannot use union as in exutabi because of long field
  393. CREATE OR REPLACE view exu7vewi AS 
  394.        SELECT vw.* from exu7vew vw, incexp i, incvid v
  395.        WHERE i.name(+) = vw.vname AND i.owner#(+) = vw.vownerid
  396.              AND v.expid < NVL(i.expid, 9999) AND NVL(i.type, 4) = 4
  397. /         
  398. rem views for cumulative export: new, last export was inc or not valid
  399. CREATE OR REPLACE view exu7vewc AS 
  400.        SELECT vw.* from exu7vew vw, incexp i, incvid v
  401.        WHERE vw.vname = i.name(+) AND vw.vownerid = i.owner#(+) AND 
  402.              NVL(i.type,4) = 4 AND
  403.              (NVL(i.ctime,TO_DATE('01-01-00','DD-MM-YY')) < i.itime OR 
  404.               v.expid < NVL(i.expid, 9999))
  405. /
  406. rem current user's view
  407. CREATE OR REPLACE view exu7vewu AS
  408.        SELECT *    from exu7vew WHERE vownerid = UID
  409. /
  410. grant select on exu7vewu to public;
  411.  
  412. rem all synonyms
  413. CREATE OR REPLACE view exu7syn (synnam, syntab, tabown, tabnode,
  414.                 public$, synown, synownid, syntime) AS
  415.        SELECT o$.name, s$.name, s$.owner, s$.node,
  416.             DECODE(o$.owner#, 1, 1, 0),
  417.              uo$.name, o$.owner#, TO_CHAR(o$.ctime, 'YYMMDDHH24MISS')
  418.        FROM sys.obj$ o$, sys.syn$ s$, sys.user$ us$, sys.user$ uo$
  419.        WHERE s$.obj# = o$.obj# AND o$.owner# = uo$.user# AND
  420.          s$.owner = us$.name(+)
  421. /
  422. rem synonyms for incremental export: new or last export not valid
  423. CREATE OR REPLACE view exu7syni AS 
  424.        SELECT s.* from exu7syn s, incexp i, incvid v
  425.        WHERE s.synnam = i.name(+) AND s.synownid = i.owner#(+) AND 
  426.              NVL(i.type,5) = 5 AND NVL(i.expid,9999) > v.expid
  427. /         
  428. rem synonyms for cumulative export: new, last export was inc or not valid
  429. CREATE OR REPLACE view exu7sync AS 
  430.        SELECT s.* from exu7syn s, incexp i, incvid v
  431.        WHERE  s.synnam  = i.name(+) AND s.synownid = i.owner#(+) AND 
  432.               NVL(i.type,5) = 5 AND
  433.           (NVL(i.ctime,TO_DATE('01-01-00','DD-MM-YY')) < i.itime OR 
  434.                NVL(i.expid,9999) > v.expid)
  435. /
  436. rem user's synnonyms
  437. CREATE OR REPLACE view exu7synu AS
  438.        SELECT * from exu7syn WHERE synownid = UID
  439. /
  440. grant select on exu7synu to public;
  441.  
  442. rem clustered tables' columns
  443. CREATE OR REPLACE view exu7cco
  444.                    (tname, towner, townerid, cluster$, tcolnam, seq) AS
  445.        SELECT t$.name, u$.name, t$.owner#, c$.name, tc$.name, cc$.col#
  446.        FROM sys.obj$ t$, sys.tab$ tab$, sys.obj$ c$,
  447.         sys.col$ tc$, sys.col$ cc$, sys.user$ u$
  448.        WHERE t$.type = 2 AND t$.obj# = tab$.obj# AND
  449.            tab$.clu# = cc$.obj# AND tab$.obj# = tc$.obj# AND 
  450.              tab$.clu# = c$.obj# AND 
  451.              cc$.segcol# = tc$.segcol# AND t$.owner# = u$.user#
  452. /
  453. rem current user's clustered tables' columns
  454. CREATE OR REPLACE view exu7ccou AS
  455.        SELECT * from exu7cco WHERE townerid = UID
  456. /
  457. grant select on exu7ccou to public;
  458.  
  459. rem all clusters
  460. CREATE OR REPLACE view exu7clu 
  461.                    (objid, owner, ownerid, name, tblspace, size$, fileno,
  462.                 blockno, mtime, pctfree$, pctused$, initrans, maxtrans,
  463.             hashkeys, function, spare4, parallel, cache) AS
  464.        SELECT o$.obj#, u$.name, o$.owner#, o$.name, ts$.name, 
  465.           NVL(c$.size$, -1), c$.file#, c$.block#, o$.mtime, c$.pctfree$, 
  466.               c$.pctused$, c$.initrans, c$.maxtrans, NVL(c$.hashkeys, 0), 
  467.           NVL(c$.func, 1), NVL(c$.spare4,-1), 
  468.           NVL(c$.spare5,0), NVL(c$.spare6,0)
  469.        FROM sys.obj$ o$, sys.clu$ c$, sys.ts$ ts$, sys.user$ u$
  470.        WHERE o$.obj# = c$.obj# AND c$.ts# = ts$.ts# AND o$.owner# = u$.user#
  471. /
  472. rem clusters for incremental export: new or last export invalid
  473. rem altered cluster is now exported because its tables are also exported
  474. CREATE OR REPLACE view exu7clui AS 
  475.        SELECT c.* from exu7clu c,incexp i, incvid v
  476.        WHERE c.name  = i.name(+) AND c.ownerid = i.owner#(+) AND
  477.         (c.mtime > i.itime OR NVL(i.expid,9999) > v.expid)
  478. /         
  479. rem clusters for cumulative export: last export was inc or new
  480. rem altered cluster is now exported because its tables are also exported
  481. CREATE OR REPLACE view exu7cluc AS 
  482.        SELECT c.* from exu7clu c,incexp i, incvid v
  483.        WHERE c.name = i.name(+) AND c.ownerid = i.owner#(+) AND 
  484.              NVL(i.type,3) = 3 AND
  485.           (i.itime > NVL(i.ctime,TO_DATE('01-01-00','DD-MM-YY'))
  486.         OR c.mtime > i.itime OR NVL(i.expid,9999) > v.expid)
  487. /
  488. rem current user's clusters
  489. CREATE OR REPLACE view exu7cluu AS
  490.        SELECT * from exu7clu WHERE ownerid = UID
  491. /
  492. grant select on exu7cluu to public;
  493.  
  494. rem all storage parameters
  495. CREATE OR REPLACE view exu7sto (ownerid, fileno, blockno, iniext, sext, minext,
  496.                     maxext, pctinc, blocks, lists, groups, extents) AS
  497.        SELECT user#, file#, block#, iniexts, extsize, minexts, maxexts, 
  498.               extpct, blocks, NVL(lists,1), NVL(groups,1), extents
  499.        FROM sys.seg$
  500.  
  501. rem storage parameters for current user's segments
  502. CREATE OR REPLACE view exu7stou AS
  503.        SELECT * from exu7sto WHERE ownerid = UID
  504. /
  505. grant select on exu7stou to public;
  506.  
  507. rem find out correct size of second extent using uet$
  508. CREATE OR REPLACE view exu7tne (fileno, blockno, length) AS
  509.     SELECT segfile#, segblock#, length
  510.     from uet$ where ext# = 1
  511. /
  512. grant select on exu7tne to public;
  513.  
  514. rem all tablespaces
  515. CREATE OR REPLACE view exu7tbs 
  516.                    (id, owner, name, isonline, iniext, sext, pctinc,
  517.             minext, maxext) AS
  518.        SELECT ts$.ts#, 'SYSTEM', ts$.name, 
  519.           DECODE(ts$.online$, 1, 'ONLINE', 4, 'ONLINE', 'OFFLINE'), 
  520.           ts$.dflinit,
  521.              ts$.dflincr, ts$.dflextpct, ts$.dflminext, ts$.dflmaxext
  522.        FROM sys.ts$ ts$ 
  523.        WHERE ts$.online$ in (1, 2, 4) and ts$.ts# != 0
  524. /
  525.  
  526. rem tablespace quotas
  527. CREATE OR REPLACE view exu7tsq(tsname, tsid, uname, userid, maxblocks) AS
  528.        SELECT t$.name, q$.ts#, u$.name, u$.user#, q$.maxblocks
  529.        FROM  sys.ts$ t$, sys.tsq$ q$, sys.user$ u$
  530.        WHERE  q$.user# = u$.user# AND q$.ts# = t$.ts# AND q$.maxblocks != 0
  531. /
  532.  
  533. rem block size
  534. CREATE OR REPLACE view exu7bsz(blocksize) AS
  535.        SELECT ts$.blocksize
  536.        FROM   sys.ts$ ts$
  537. /
  538. grant select on exu7bsz to public;
  539.  
  540. rem all files
  541. CREATE OR REPLACE view exu7fil(fname, fsize, tsid) AS
  542.        SELECT v$.name, f$.blocks, f$.ts#
  543.        FROM   sys.file$ f$, sys.v$dbfile v$
  544.        WHERE  f$.file# = v$.file#
  545. /
  546.  
  547. rem all database links
  548. CREATE OR REPLACE view exu7lnk 
  549.                    (owner, ownerid, name, user$, passwd, host, public$) AS
  550.        SELECT DECODE(l$.owner#, 1, 'SYSTEM', u$.name), l$.owner#, l$.name, 
  551.               l$.userid, l$.password, l$.host, DECODE(l$.owner#, 1, 1, 0)
  552.        FROM sys.user$ u$, sys.link$ l$
  553.        WHERE u$.user# = l$.owner#
  554. /
  555. CREATE OR REPLACE view exu7lnku AS        /* current user's database links */
  556.        SELECT * from exu7lnk WHERE ownerid = UID
  557. /
  558. grant select on exu7lnku to public;
  559.  
  560. rem all rollback segments
  561. CREATE OR REPLACE view exu7rsg 
  562.                    (owner, name, space$, fileno , blockno, minext, public$) AS 
  563.        SELECT 'SYSTEM', r$.name, ts$.name, r$.file#, r$.block#, s$.minexts,
  564.              DECODE(r$.user#, 1, 1, 0)
  565.        FROM sys.ts$ ts$, sys.undo$ r$, sys.seg$ s$
  566.        WHERE r$.status$ != 1 AND r$.file# = s$.file# AND r$.block# = s$.block#
  567.              AND s$.ts# = ts$.ts# and r$.us# != 0
  568. /
  569.  
  570. rem info on deleted objects EXCEPT snapshots, snapshot logs
  571. CREATE OR REPLACE view exu7del (owner, name, type, type#) AS
  572.        SELECT u$.name, i$.name, DECODE(i$.type, 2, 'TABLE', 3, 
  573.               'CLUSTER', 4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE', 
  574.           7, 'PROCEDURE', 8, 'FUNCTION', 9, 'PACKAGE',
  575.          -1, 'TRIGGER', -4, 'PACKAGE BODY'), i$.type
  576.        FROM sys.incexp i$, sys.user$ u$
  577.        WHERE i$.owner# = u$.user#
  578.          AND i$.type NOT IN (-2,-3)
  579.          AND (i$.owner#, i$.name, i$.type) 
  580.              NOT IN (SELECT o$.owner#, o$.name, 
  581.              DECODE(o$.type, 12, -1, 11, -4, o$.type) 
  582.              FROM   sys.obj$ o$
  583.                      WHERE  o$.linkname is null
  584.             )
  585. /
  586.  
  587. rem info on sequence number
  588. CREATE OR REPLACE view exu7seq 
  589.                    (owner, ownerid, name, objid, curval, minval, maxval, 
  590.             incr, cache, cycle, order$, audt) AS
  591.        SELECT u.name, u.user#, o.name, o.obj#, s.highwater, s.minvalue, 
  592.           s.maxvalue, s.increment$, s.cache, s.cycle, s.order$, s.audit$
  593.        FROM sys.obj$ o, sys.user$ u, sys.seq$ s
  594.        WHERE o.obj# = s.obj# AND o.owner# = u.user#
  595. /
  596. CREATE OR REPLACE view exu7sequ AS 
  597.        SELECT * from sys.exu7seq WHERE UID = ownerid
  598. /
  599. grant select on sys.exu7sequ to public;
  600.  
  601. rem contraints on table
  602. CREATE OR REPLACE view exu7con 
  603.                    (objid, owner, ownerid, tname, type, cname, cno, condition,
  604.                     condlength, enabled) AS
  605.        SELECT o.obj#, u.name, c.owner#, o.name, cd.type, c.name,
  606.               c.con#, cd.condition, cd.condlength, NVL(cd.enabled,0)
  607.        FROM sys.obj$ o, sys.user$ u, sys.con$ c, sys.cdef$ cd
  608.        WHERE u.user# = c.owner# AND o.obj# = cd.obj# AND cd.con# = c.con#
  609. /
  610. CREATE OR REPLACE view exu7conu AS 
  611.        SELECT * from sys.exu7con WHERE UID = ownerid
  612. /
  613. grant select on sys.exu7conu to public;
  614.  
  615. rem referential constraints
  616. CREATE OR REPLACE view exu7ref 
  617.                    (objid, owner, ownerid, tname, rowner, rtname, cname, cno,
  618.                 rcno, action, enabled) AS
  619.        SELECT o.obj#, u.name, c.owner#, o.name, ru.name, ro.name, 
  620.               DECODE(SUBSTR(c.name, 1, 5), 'SYS_C', '', NVL(c.name, '')),
  621.           c.con#, cd.rcon#, NVL(cd.refact,0), NVL(cd.enabled,0)
  622.        FROM sys.user$ u, sys.user$ ru, sys.obj$ o, sys.obj$ ro, 
  623.             sys.con$ c, sys.cdef$ cd
  624.        WHERE u.user# = c.owner# AND o.obj# = cd.obj# AND ro.obj# = cd.robj# AND
  625.              cd.con# = c.con# AND cd.type = 4 AND ru.user# = ro.owner#
  626. /
  627. CREATE OR REPLACE view exu7refu AS SELECT * from sys.exu7ref WHERE UID = ownerid
  628. /
  629. grant select on sys.exu7refu to public;
  630. rem referential constraints for incremental and cumulative export
  631. rem for tables just exported, i.expid will be greater than v.expid
  632. rem as v.expid is incremented only at the end of the incremental export
  633. rem but i.expid is incremented when the table is exported.
  634. rem USED ONLY WHEN REOCRD = YES
  635. CREATE OR REPLACE view exu7refic AS
  636.        SELECT * from sys.exu7ref 
  637.        WHERE (ownerid, tname) in 
  638.              (SELECT i.owner#, i.name 
  639.               FROM sys.incexp i, sys.incvid v
  640.               WHERE i.expid > v.expid AND i.type = 2)
  641. /
  642. rem referentail constraints for incremental export
  643. rem exutabi will return the correct table name because RECORD = NO
  644. CREATE OR REPLACE view exu7refi AS
  645.        SELECT * from sys.exu7ref
  646.        WHERE (ownerid, tname) in (SELECT ownerid, name from sys.exu7tabi)
  647. /
  648. rem referentail constraints for cumulative export, assuming
  649. rem exutabc will return the correct table name because RECORD = NO
  650. CREATE OR REPLACE view exu7refc AS
  651.        SELECT * from sys.exu7ref
  652.        WHERE (ownerid, tname) in (SELECT ownerid, name from sys.exu7tabc)
  653. /
  654.  
  655. rem contraint column list
  656. CREATE OR REPLACE view exu7ccl (ownerid, cno, colname, colno) AS
  657.        SELECT o.owner#, cc.con#, c.name, cc.pos#
  658.        FROM sys.obj$ o, sys.col$ c, sys.ccol$ cc
  659.        WHERE o.obj# = cc.obj# AND c.obj# = cc.obj# AND cc.col# = c.col#
  660. /
  661. CREATE OR REPLACE view exu7cclu AS
  662.        SELECT * from sys.exu7ccl WHERE UID = ownerid
  663. /
  664. grant select on sys.exu7cclu to public;
  665. /
  666. CREATE OR REPLACE view exu7cclo (ownerid, cno, colname, colno) AS
  667.     SELECT a.ownerid, a.cno, a.colname, a.colno
  668.     from sys.exu7ccl a, sys.con$ b , sys.cdef$ c
  669.     WHERE b.owner#=UID
  670.     AND   b.con# = c.con#
  671.     AND   c.rcon# = a.cno
  672. /
  673. grant select on sys.exu7cclo to public
  674. /
  675. rem triggers
  676. CREATE OR REPLACE view exu7tgr 
  677.                    (ownerid, owner, baseobject, definition, whenclause, 
  678.                 actionsize, action, enabled, name, basename) AS
  679.         SELECT o.owner#, u.name, t.baseobject, t.definition, t.whenclause, 
  680.            t.actionsize, t.action, t.enabled, o.name, o2.name
  681.         FROM sys.obj$ o, sys.trigger$ t, sys.user$ u, sys.obj$ o2
  682.         WHERE o.obj# = t.obj# AND u.user# = o.owner# AND
  683.           o2.obj# = t.baseobject
  684. /
  685. CREATE OR REPLACE view exu7tgru AS
  686.         SELECT * from sys.exu7tgr WHERE UID = ownerid
  687. /
  688. grant select on sys.exu7tgru to public;
  689. /
  690. rem triggers for incremental and cumulative export for table just 
  691. rem exported.  See comment on exu7refic.
  692. CREATE OR REPLACE view exu7tgric as 
  693.     SELECT * from sys.exu7tgr 
  694.     WHERE (ownerid, basename) in
  695.              (SELECT i.owner#, i.name
  696.               from sys.incexp i, sys.incvid v
  697.               WHERE i.expid > v.expid AND i.type = 2)
  698. /
  699. rem triggers for incremental export: record=no
  700. CREATE OR REPLACE view exu7tgri as 
  701.        SELECT * from sys.exu7tgr
  702.     WHERE (ownerid, basename) in (SELECT ownerid, name from sys.exu7tabi)
  703. /
  704. rem triggers for cumulative export: record=no
  705. CREATE OR REPLACE view exu7tgrc as 
  706.        SELECT * from sys.exu7tgr 
  707.     WHERE (ownerid, basename) in (SELECT ownerid, name from sys.exu7tabc)
  708. /
  709. CREATE OR REPLACE view exu7spr(ownerid, uname, id, name, time, typeid, type,
  710.      audt) AS
  711.    SELECT o.owner#, u.name, o.obj#, o.name, 
  712.       TO_CHAR(o.mtime, 'YYYY-MM-DD:HH24:MI:SS'), o.type,
  713.           DECODE(o.type, 7, 'PROCEDURE', 8, 'FUNCTION', 
  714.              9, 'PACKAGE', 11, 'PACKAGE BODY'), p.audit$
  715.    FROM sys.obj$ o, sys.user$ u, sys.procedure$ p
  716.    WHERE o.owner# = u.user# AND (o.type=7 OR o.type=8 OR o.type=9 OR o.type=11)
  717.     AND o.obj# = p.obj#
  718. /
  719. CREATE OR REPLACE view exu7spu(ownerid, uname, id, name, time, typeid, type,
  720.     audt) AS
  721.    SELECT * from sys.exu7spr WHERE UID = ownerid
  722. /
  723. grant select on sys.exu7spu to public
  724. /
  725. rem stored procedures for incremental export: modified, altered or new
  726. CREATE OR REPLACE view exu7spri AS
  727.        SELECT s.* from exu7spr s,incexp i, incvid v
  728.        WHERE s.name  = i.name(+) AND s.ownerid = i.owner#(+) AND
  729.              NVL(i.type,7) = 7 AND
  730.              NVL(i.expid,9999) > v.expid
  731. /
  732. rem stored procedures for incremental export: modified, altered or new
  733. CREATE OR REPLACE view exu7sprc AS
  734.        SELECT s.* from exu7spr s,incexp i, incvid v
  735.        WHERE s.name  = i.name(+) AND s.ownerid = i.owner#(+) AND
  736.              NVL(i.type,7) = 7 AND
  737. (NVL(i.ctime,TO_DATE('01-01-00','DD-MM-YY')) < i.itime OR
  738.                NVL(i.expid,9999) > v.expid)
  739. /
  740. CREATE OR REPLACE view exu7sps(obj#, line, source) AS
  741.    SELECT obj#,line,source 
  742.    FROM sys.source$ 
  743. /
  744. CREATE OR REPLACE view exu7spsu(obj#, line, source) AS
  745.    SELECT s.obj#, s.line, s.source
  746.    FROM sys.source$ s, sys.obj$ o
  747.    WHERE s.obj# = o.obj# and o.owner# = UID
  748. /
  749. grant select on sys.exu7spsu to public
  750. /
  751. rem system auditting options
  752. CREATE OR REPLACE view exu7aud (userid, name, action, success, failure) AS
  753.     SELECT a.user#, u.name, m.name, NVL(a.success,0), NVL(a.failure,0)
  754.     FROM sys.audit$ a, sys.user$ u, sys.stmt_audit_option_map m
  755.     WHERE a.user# = u.user# AND a.option# = m.option#
  756. /
  757. rem profiles
  758. CREATE OR REPLACE view exu7prf(profile#, name) AS
  759.     SELECT profile#, name 
  760.     FROM sys.profname$
  761.     WHERE profile# != 0
  762. /
  763. CREATE OR REPLACE view exu7prr(profile#, resname, limit) AS
  764.     SELECT profile#, DECODE(resource#,
  765.         0, 'COMPOSITE_LIMIT',
  766.         1, 'SESSIONS_PER_USER',
  767.         2, 'CPU_PER_SESSION',
  768.         3, 'CPU_PER_CALL',
  769.         4, 'LOGICAL_READS_PER_SESSION',
  770.         5, 'LOGICAL_READS_PER_CALL',
  771.         6, 'IDLE_TIME',
  772.         7, 'CONNECT_TIME',
  773.         8, 'PRIVATE_SGA', 'UNDEFINED'), limit
  774.     FROM sys.profile$
  775.     WHERE resource# != 9 and type = 0
  776. /
  777. rem snapshots
  778. CREATE OR REPLACE view exu7snap
  779. ( OWNER, OWNERID, NAME, TABLE_NAME, MASTER_VIEW, MASTER_OWNER, MASTER, 
  780.   MASTER_LINK, CAN_USE_LOG, LAST_REFRESH, ERROR, TYPE, NEXT, START_WITH, QUERY,
  781.   UPDATABLE, UPDATE_TRIG, UPDATE_LOG)
  782. as
  783. SELECT sowner, u.user#, vname, tname, mview, mowner, master, mlink,
  784.        decode(can_use_log, null, 'NO', 'YES'), 
  785.        snaptime, error#, 
  786.        decode(auto_fast, 
  787.               'C', 'COMPLETE', 
  788.               'F', 'FAST', 
  789.               '?', 'FORCE', 
  790.               null, 'FORCE', 'ERROR'), 
  791.        auto_fun, auto_date, query_txt, mod(trunc(flag/2),2), ustrg, uslog
  792. from sys.snap$ s, sys.user$ u
  793. WHERE u.name = s.sowner
  794. /
  795. CREATE OR REPLACE view exu7snapu
  796. ( OWNER, OWNERID, NAME, TABLE_NAME, MASTER_VIEW, MASTER_OWNER, MASTER, 
  797.   MASTER_LINK, CAN_USE_LOG, LAST_REFRESH, ERROR, TYPE, NEXT, START_WITH, QUERY,
  798.   UPDATABLE, UPDATE_TRIG, UPDATE_LOG)
  799. as
  800. SELECT sowner, u.user#, vname, tname, mview, mowner, master, mlink,
  801.        decode(can_use_log, null, 'NO', 'YES'), 
  802.        snaptime, error#, 
  803.        decode(auto_fast, 
  804.               'C', 'COMPLETE', 
  805.               'F', 'FAST', 
  806.               '?', 'FORCE', 
  807.               null, 'FORCE', 'ERROR'), 
  808.        auto_fun, auto_date, query_txt, mod(trunc(flag/2),2), ustrg, uslog
  809. from sys.snap$ s, sys.user$ u
  810. WHERE u.name = s.sowner
  811. and UID = u.user#
  812. /
  813. grant SELECT on sys.exu7snapu to public;
  814.  
  815. rem snapshots for incremental export: modified, altered or new
  816. CREATE OR REPLACE view exu7snapi AS
  817.         SELECT s.* from exu7snap s,incexp i, incvid v
  818.        WHERE s.name  = i.name(+) AND s.ownerid = i.owner#(+) AND
  819.              NVL(i.type,-2) = -2 AND
  820.              NVL(i.expid,9999) > v.expid
  821. /
  822. rem snapshots for cumulative export: new, last export was inc or not valid
  823. CREATE OR REPLACE view exu7snapc AS
  824.        SELECT s.* from exu7snap s, incexp i, incvid v
  825.        WHERE  s.name  = i.name(+) AND s.ownerid = i.owner#(+) AND
  826.               NVL(i.type,-2) = -2 AND
  827.               (NVL(i.ctime,TO_DATE('01-01-00','DD-MM-YY')) < i.itime OR
  828.                NVL(i.expid,9999) > v.expid)
  829. /
  830. rem snapshot logs
  831. CREATE OR REPLACE view exu7snapl
  832. ( LOG_OWNER, LOG_OWNERID, MASTER, LOG_TABLE, LOG_TRIGGER)
  833. as
  834. SELECT m.mowner, u.user#, m.master, m.log, m.trig
  835. from sys.mlog$ m, sys.user$ u
  836. WHERE m.mowner = u.name
  837. /
  838.  
  839. CREATE OR REPLACE view exu7snaplu
  840. ( LOG_OWNER, LOG_OWNERID, MASTER, LOG_TABLE, LOG_TRIGGER)
  841. as
  842. SELECT m.mowner, u.user#, m.master, m.log, m.trig
  843. from sys.mlog$ m,  sys.user$ u
  844. WHERE  m.mowner = u.name
  845.   and UID = u.user#
  846. /
  847. grant SELECT on sys.exu7snaplu to public;
  848.  
  849. rem snapshot logs for incremental export: modified, altered or new
  850. CREATE OR REPLACE view exu7snapli AS
  851.         SELECT s.* from exu7snapl s,incexp i, incvid v
  852.        WHERE s.master  = i.name(+) AND s.log_ownerid = i.owner#(+) AND
  853.              NVL(i.type,-3) = -3 AND
  854.              NVL(i.expid,9999) > v.expid
  855. /
  856. rem snapshot logs for cumulative export: new, last export was inc or not valid
  857. CREATE OR REPLACE view exu7snaplc AS
  858.        SELECT s.* from exu7snapl s, incexp i, incvid v
  859.        WHERE s.master  = i.name(+) AND s.log_ownerid = i.owner#(+) AND
  860.               NVL(i.type,-3) = -3 AND
  861.               (NVL(i.ctime,TO_DATE('01-01-00','DD-MM-YY')) < i.itime OR
  862.                NVL(i.expid,9999) > v.expid)
  863. /
  864.  
  865. rem info on deleted snapshots -- they aren't in obj$
  866. CREATE OR REPLACE view exu7delsnap (owner, name, type) as
  867.        SELECT u$.name, i$.name, 'SNAPSHOT'
  868.        from sys.incexp i$, sys.user$ u$
  869.        WHERE i$.owner# = u$.user# and
  870.          i$.type = -2 and
  871.              (u$.name, i$.name)
  872.              NOT IN (SELECT s$.sowner, s$.vname
  873.              from sys.snap$ s$)
  874. /
  875. rem info on deleted snapshot logs -- they aren't in obj$
  876. CREATE OR REPLACE view exu7delsnapl (owner, name, type) as
  877.        SELECT u$.name, i$.name, 'SNAPSHOT LOG'
  878.        from sys.incexp i$, sys.user$ u$
  879.        WHERE i$.owner# = u$.user# and
  880.          i$.type = -3 and
  881.              (u$.name, i$.name)
  882.              NOT IN (SELECT m$.mowner, m$.master
  883.              from sys.mlog$ m$)
  884. /
  885.  
  886. rem info on analyzed objects
  887. CREATE OR REPLACE view exu7anal(id,rowcnt) as
  888.     select obj#, NVL(rowcnt,-1) from sys.tab$;
  889. grant select on exu7anal to public
  890. /
  891. rem check if user has priv to do a full db export
  892. CREATE OR REPLACE view exu7ful(role) as
  893. select u.name
  894. from x$kzsro, user$ u
  895. where kzsrorol!=uid and kzsrorol!=1 and u.user#=kzsrorol
  896. /
  897. grant select on sys.exu7ful to public;
  898.  
  899. rem add a view to determine storage clause for unique constraint
  900. rem need for it to be user level because two different users can have the
  901. rem same index name 
  902. CREATE OR REPLACE view exu7uscu 
  903. (iobjid, iname, ifileno, iblockno, ibobjid, tspname) as
  904.     SELECT o$.obj#, o$.name, i$.file#, i$.block#, i$.bo#, t$.name
  905.     from sys.obj$ o$, sys.ind$ i$, sys.file$ f$, sys.ts$ t$
  906.     where o$.obj# = i$.obj# and unique$ = 1 and f$.file#=i$.file#
  907.     and f$.ts# = t$.ts#
  908. /
  909. grant select on sys.exu7uscu to public; 
  910.  
  911. rem referential constraints
  912. CREATE OR REPLACE view exu7rif 
  913.                    (objid, owner, ownerid, tname, rowner, rtname, cname, cno,
  914.                 rcno, action, enabled, robjid) AS
  915.        SELECT o.obj#, u.name, c.owner#, o.name, ru.name, ro.name, 
  916.               DECODE(SUBSTR(c.name, 1, 5), 'SYS_C', '', NVL(c.name, '')),
  917.           c.con#, cd.rcon#, NVL(cd.refact,0), NVL(cd.enabled,0),
  918.           cd.robj#
  919.        FROM sys.user$ u, sys.user$ ru, sys.obj$ o, sys.obj$ ro, 
  920.             sys.con$ c, sys.cdef$ cd
  921.        WHERE u.user# = c.owner# AND o.obj# = cd.obj# AND ro.obj# = cd.robj# AND
  922.              cd.con# = c.con# AND cd.type = 4 AND ru.user# = ro.owner#
  923. /
  924. CREATE OR REPLACE view exu7erc
  925.         (resource_name, unit_cost) as
  926.         SELECT m.name, c.cost 
  927.         FROM sys.resource_cost$ c, sys.resource_map m 
  928.         WHERE c.resource# = m.resource#
  929.             AND c.resource# in (2, 4, 7, 8)
  930. /
  931.  
  932. REM
  933. REM Job Queues
  934. REM
  935. CREATE OR REPLACE view exu7jbq
  936.             (job, ownerid, owner) as
  937.         SELECT j$.job, u$.user#, j$.powner
  938.         FROM sys.job$ j$, sys.user$ u$
  939.         WHERE j$.powner = u$.name
  940. /
  941.  
  942. CREATE OR REPLACE view exu7jbqu 
  943.         (job, ownerid, owner) as
  944.         SELECT * FROM sys.exu7jbq 
  945.         WHERE uid = ownerid
  946. /
  947. grant select on exu7jbqu to public
  948. /
  949. REM
  950. REM Refresh Groups
  951. REM
  952. CREATE OR REPLACE view exu7rgs 
  953.         (refgroup, ownerid, owner) as
  954.         SELECT r$.refgroup, u$.user#, r$.owner
  955.         FROM sys.rgroup$ r$, sys.user$ u$
  956.         WHERE r$.owner = u$.name
  957. /
  958.  
  959. CREATE OR REPLACE view exu7rgsu
  960.         (refgroup, ownerid, owner) as
  961.         SELECT * from sys.exu7rgs
  962.         WHERE uid = ownerid
  963. /
  964. grant select on exu7rgsu to public
  965. /
  966. REM
  967. REM Refresh Group Children
  968. REM
  969. CREATE OR REPLACE view exu7rgc
  970.         (owner, ownerid, child, type, refgroup) as
  971.         SELECT rc$.owner, u$.user#, rc$.name, rc$.type, rc$.refgroup
  972.         FROM sys.rgchild$ rc$, sys.user$ u$
  973.         WHERE rc$.owner = u$.name
  974. /
  975.  
  976. CREATE OR REPLACE view exu7rgcu
  977.         (owner, ownerid,  child, type, refgroup) as
  978.         SELECT * from sys.exu7rgc
  979.         WHERE uid = ownerid
  980. /
  981. grant select on exu7rgcu to public
  982. /
  983. REM
  984. REM PoSTtables actions 
  985. REM
  986. /
  987. CREATE OR REPLACE view exu7pst
  988.         (owner, ownerid, tname, tobjid, callorder) as
  989.         SELECT a$.owner, u$.user#, a$.name, o$.obj#, a$.callorder
  990.         FROM sys.expact$ a$, sys.user$ u$, sys.obj$ o$
  991.         WHERE u$.name = a$.owner and o$.owner# = u$.user#
  992.               and o$.name = a$.name 
  993. /
  994.  
  995. CREATE OR REPLACE view exu7pstu
  996.         (owner, ownerid, tname, tobjid, callorder) as
  997.         SELECT * from sys.exu7pst
  998.             where ownerid = uid
  999. /
  1000. grant select on exu7pstu to public
  1001. /
  1002.  
  1003. REM PoSTtables actions incremental/cumulative with record = Y
  1004. CREATE OR REPLACE view exu7pstic
  1005.         (owner, ownerid, tname, tobjid, callorder) as
  1006.         SELECT * from sys.exu7pst
  1007.         WHERE (ownerid, tname) in
  1008.             (SELECT i.owner#, i.name
  1009.                  FROM sys.incexp i, sys.incvid v
  1010.                  WHERE i.expid > v.expid AND i.type = 2)
  1011. /
  1012. REM PoSTtables actions for incremental export : record = N
  1013. CREATE OR REPLACE view exu7psti as
  1014.         SELECT * from sys.exu7pst
  1015.         WHERE (ownerid, tname) in 
  1016.         (SELECT ownerid, name from sys.exu7tabi)
  1017. /
  1018. REM PoSTtables actions for cumulative  export : record = N
  1019. CREATE OR REPLACE view exu7pstc as
  1020.         SELECT * from sys.exu7pst
  1021.         WHERE (ownerid, tname) in 
  1022.         (SELECT ownerid, name from sys.exu7tabc)
  1023. /
  1024.  
  1025. REM Version Control
  1026. CREATE OR REPLACE view exu7ver (version) AS
  1027.             SELECT TO_NUMBER(value$) from sys.props$
  1028.         WHERE name = 'EXPORT_VIEWS_VERSION'
  1029. /
  1030. grant select on exu7ver to public
  1031. /
  1032.