home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a524 / 28.ddi / admin / expvew.sql < prev    next >
Encoding:
Text File  |  1991-03-04  |  18.1 KB  |  489 lines

  1. rem 
  2. rem $Header: expvew.sql,v 6002300.1 89/06/16 01:21:25 cyang Exp $ expvew.sql Copyr (c) 1987 Oracle
  3. rem 
  4. rem RDBMS660023,DISK$DEV1:[V6SOURCE.OLB.60023]
  5. Rem Copyright (c) 1987 by Oracle Corporation
  6. Rem NAME
  7. Rem    EXPVEW.SQL - IMPORT/EXPORT VIEWS
  8. Rem  FUNCTION
  9. Rem  NOTES
  10. Rem    Must be run when connected to SYS.
  11. Rem  MODIFIED
  12. Rem   Hong       10/31/88 - don't export quotas of 0
  13. Rem   Hong       09/21/88 - allow null precision/scale
  14. Rem   Hong       09/10/88 - fix outer joins
  15. Rem   Hong       08/10/88 - get default/temp tablespace in exuusr
  16. Rem   Hong       07/01/88 - get obj id in some views
  17. Rem   Hong       06/10/88 - remove userid != 0 from views
  18. Rem   Hong       04/28/88 - comment$ moved to com$
  19. Rem   Hong       03/24/88 - add audit field to exuseq
  20. Rem   Hong       03/07/88 - deal with initrans, maxtrans
  21. Rem                         add views for constraints, sequence #
  22. Rem   Hong       02/01/88 - add exuico and exuicou
  23. Rem                         temporary commented out col$.default$
  24. Rem   Hong       02/01/88 - fix exufil to use v$dbfile directly
  25. Rem   Hong       12/12/87 - fix exutbs
  26. Rem   Hong       12/07/87 - handle min extents 
  27. Rem
  28.  
  29. set echo on;
  30.  
  31. rem all tables
  32. drop view exutab;
  33. CREATE VIEW exutab (objid,name, owner, ownerid, tablespace, fileno, blockno,
  34.             audit$, comment$, clusterflag, mtime, modified,
  35.                     pctfree$, pctused$, initrans, maxtrans) AS
  36.        SELECT o$.obj#,o$.name, u$.name, o$.owner#, ts$.name, t$.file#, 
  37.           t$.block#, t$.audit$, c$.comment$, NVL(t$.clu#, 0), o$.mtime,
  38.           t$.modified, t$.pctfree$, t$.pctused$, t$.initrans, t$.maxtrans
  39.        FROM sys.tab$ t$, sys.obj$ o$, sys.ts$ ts$, sys.user$ u$, sys.com$ c$
  40.        WHERE  t$.obj# = o$.obj# and t$.ts# = ts$.ts# and 
  41.               u$.user# = o$.owner# and o$.obj# = c$.obj#(+) 
  42.           and c$.col#(+) is null
  43. /
  44. rem tables for incremental export: modified, altered or new
  45. drop view exutabi;
  46. CREATE VIEW exutabi AS 
  47.        SELECT t.* FROM exutab t,incexp i, incvid v
  48.        WHERE t.name  = i.name(+) AND t.ownerid = i.owner#(+) AND
  49.              NVL(i.type,2) = 2 AND  
  50.              (t.modified = 1 OR t.mtime > i.itime OR 
  51.               NVL(i.expid,9999) > v.expid)
  52. /         
  53. rem tables for cumulative export: modified, last export was inc, altered or new
  54. drop view exutabc;
  55. CREATE VIEW exutabc AS 
  56.        SELECT t.* FROM exutab t,incexp i, incvid v
  57.        WHERE  t.name  = i.name(+) AND t.ownerid = i.owner#(+) AND 
  58.              NVL(i.type,2) = 2 AND 
  59.               (t.modified = 1 OR i.itime > NVL(i.ctime,
  60.                                              TO_DATE('01-JAN-01','DD-MON-YY'))
  61.                OR t.mtime > i.itime OR NVL(i.expid,9999) > v.expid)
  62. /
  63. rem current user's tables 
  64. drop view exutabu;
  65. CREATE VIEW exutabu AS
  66.        SELECT * FROM exutab WHERE ownerid = uid
  67. /
  68. grant select on exutabu to public;
  69.  
  70. rem all columns 
  71. drop view exucol;
  72. CREATE VIEW exucol (tobjid, towner, townerid, tname, name, length, precision, 
  73.             scale, type, isnull, conname, colid, comment$, default$, 
  74.                 dfltlen) AS
  75.        SELECT o$.obj#, u$.name, o$.owner#, o$.name, c$.name, c$.length, 
  76.               c$.precision, c$.scale, c$.type#, c$.null$, 
  77.               DECODE(SUBSTR(con$.name,1,5), 'SYS_C', '', NVL(con$.name, '')),
  78.               c$.col#, com$.comment$, c$.default$, NVL(c$.deflength, 0)
  79.        FROM sys.col$ c$, sys.obj$ o$, sys.user$ u$, sys.cdef$ cd$, 
  80.         sys.con$ con$, sys.com$ com$
  81.        WHERE c$.obj# = o$.obj# and o$.owner# = u$.user# and 
  82.           c$.null$ = cd$.con#(+) and c$.obj# = cd$.obj#(+) and 
  83.              cd$.con# = con$.con#(+) and 
  84.          c$.obj# = com$.obj#(+) and c$.col# = com$.col#(+)
  85. /
  86. drop view exucolu;
  87. CREATE VIEW exucolu AS                   /* current user's columns */
  88.        SELECT * from exucol WHERE townerid = uid
  89. /
  90. grant select on exucolu to public;
  91.  
  92. rem all columns for index
  93. drop view exuico;
  94. CREATE VIEW exuico (tobjid, towner, townerid, tname, name, length, precision,
  95.             scale, type, isnull, conname, colid, comment$, default$, 
  96.             dfltlen) AS
  97.        SELECT o$.obj#, u$.name, o$.owner#, o$.name, c$.name, 0, 0, 0, 0, 0, '',
  98.               i$.pos#, NULL, NULL, 0
  99.        FROM sys.col$ c$, sys.icol$ i$, sys.obj$ o$, sys.user$ u$
  100.        WHERE c$.obj# = i$.bo# and c$.col# = i$.col# and 
  101.          i$.obj# = o$.obj# and o$.owner# = u$.user#
  102. /
  103. drop view exuicou;
  104. CREATE VIEW exuicou AS                   /* current user's columns */
  105.        SELECT * from exuico WHERE townerid = uid
  106. /
  107. grant select on exuicou to public;
  108.  
  109. rem all users
  110. drop view exuusr;
  111. CREATE VIEW exuusr (name, userid, passwd, privs, datats, tempts) AS 
  112.        SELECT u.name, u.user#, u.password, 
  113.           DECODE(u.connect$, 1, 'Y', 'N')||DECODE(u.dba$, 1, 'Y', 'N')||
  114.           DECODE(u.resource$, 1, 'Y', 'N'), ts1.name, ts2.name
  115.        FROM sys.user$ u, sys.ts$ ts1, sys.ts$ ts2
  116.        WHERE u.datats# = ts1.ts# and u.tempts# = ts2.ts#
  117. /
  118. drop view exuusru;
  119. CREATE VIEW exuusru AS                         /* current user */
  120.        SELECT * FROM exuusr WHERE userid = UID
  121. /
  122. grant select on exuusru to public;
  123.  
  124. rem all grants
  125. drop view exugrn;
  126. CREATE VIEW exugrn (objid, grantor, grantorid, grantee, privs,
  127.                     creatorid, time) AS
  128.        SELECT t$.obj#, ur$.name, t$.grantor#, ue$.name, 
  129.           DECODE(t$.alter$, 0, 'N', 2, 'Y', 'G') ||
  130.           DECODE(t$.delete$, 0, 'N', 2,  'Y', 'G') ||
  131.           DECODE(t$.index$, 0, 'N', 2, 'Y', 'G') ||
  132.           DECODE(t$.insert$, 0, 'N', 2, 'Y', 'G') ||
  133.           DECODE(t$.select$, 0, 'N', 2, 'Y', 'G') ||
  134.           DECODE(t$.update$, 0, 'N', 1, 'R', 2, 'Y', 'G'),
  135.           o$.owner#, t$.time
  136.        FROM sys.tabauth$ t$, sys.obj$ o$, sys.user$ ur$,
  137.         sys.user$ ue$
  138.        WHERE o$.obj# = t$.obj# AND
  139.              t$.grantor# = ur$.user# AND t$.grantee# = ue$.user#
  140. /
  141. rem first level grants
  142. drop view exugrnu;
  143. CREATE VIEW exugrnu AS
  144.        SELECT * FROM exugrn WHERE grantorid = UID AND creatorid = UID
  145. /
  146. grant select on exugrnu to public;
  147.  
  148. rem all column grants
  149. drop view exucgr;
  150. CREATE VIEW exucgr (objid, grantor, grantorid, grantee, creatorid, cname, 
  151.                 time, wgo) AS
  152.        SELECT c$.obj#, ur$.name, c$.grantor#, ue$.name, o$.owner#, c$.name,
  153.           c$.time, DECODE(c$.update$, 3, 1, 0)
  154.        FROM sys.colauth$ c$, sys.obj$ o$, sys.user$ ur$, sys.user$ ue$
  155.        WHERE c$.grantor# = ur$.user# AND c$.grantee# = ue$.user# AND
  156.              c$.obj# = o$.obj#
  157. /
  158. rem first level grants
  159. drop view exucgru;
  160. CREATE VIEW exucgru AS
  161.        SELECT * FROM exucgr WHERE grantorid = UID AND creatorid = UID
  162. /
  163. grant select on exucgru to public;
  164.  
  165. rem all indexes
  166. drop view exuind;
  167. CREATE VIEW exuind (iobjid, iname, iowner, iownerid, ispace, ifileno, iblockno,
  168.             btname, btobjid, btowner, btownerid, unique$,
  169.             cluster$, pctfree$, initrans, maxtrans)  AS
  170.        SELECT i$.obj#, i$.name, ui$.name, i$.owner#, ts$.name, ind$.file#,
  171.           ind$.block#, t$.name, t$.obj#, ut$.name, t$.owner#,
  172.               ind$.unique$, DECODE(t$.type, 3, 1, 0), ind$.pctfree$, 
  173.           ind$.initrans, ind$.maxtrans
  174.        FROM  sys.obj$ t$, sys.obj$ i$, sys.ind$ ind$,
  175.          sys.user$ ui$, sys.user$ ut$, sys.ts$ ts$
  176.        WHERE ind$.bo# = t$.obj# AND ind$.obj# = i$.obj# AND
  177.          ts$.ts# = ind$.ts# AND i$.owner# = ui$.user# AND
  178.              t$.owner# = ut$.user#
  179. /
  180. rem current user indexes
  181. drop view exuindu;
  182. CREATE VIEW exuindu AS
  183.        SELECT * FROM exuind WHERE iownerid = UID and btownerid = UID
  184. /
  185. grant select on exuindu to public;
  186.  
  187. rem all views 
  188. drop view exuvew;
  189. CREATE VIEW exuvew (vobjid,vname, vlen, vtext, vowner, vownerid,
  190.             vtime, vaudit, vcomment, vcname) AS
  191.        SELECT o$.obj#, o$.name, v$.textlength, v$.text, u$.name, o$.owner#, 
  192.             TO_CHAR(o$.ctime, 'YYMMDDHH24MISS'), v$.audit$, com$.comment$,
  193.               DECODE(SUBSTR(c$.name,1,5), 'SYS_C', '', NVL(c$.name, ''))
  194.        FROM sys.obj$ o$, sys.view$ v$, sys.user$ u$, sys.cdef$ cd$,
  195.             sys.con$ c$, sys.com$ com$
  196.        WHERE o$.obj# = v$.obj# AND o$.owner# = u$.user# AND
  197.          o$.obj# = cd$.obj#(+) AND cd$.con# = c$.con#(+) AND 
  198.              o$.obj# = com$.obj#(+) AND com$.col#(+) is null
  199. /
  200. rem views for incremental export: new or last export not valid
  201. rem cannot use union as in exutabi because of long field
  202. drop view exuvewi;
  203. CREATE VIEW exuvewi AS 
  204.        SELECT vw.* FROM exuvew vw, incexp i, incvid v
  205.        WHERE i.name(+) = vw.vname AND i.owner#(+) = vw.vownerid
  206.              AND v.expid < NVL(i.expid, 9999) AND NVL(i.type, 4) = 4
  207. /         
  208. rem views for cumulative export: new, last export was inc or not valid
  209. drop view exuvewc;
  210. CREATE VIEW exuvewc AS 
  211.        SELECT vw.* FROM exuvew vw, incexp i, incvid v
  212.        WHERE vw.vname = i.name(+) AND vw.vownerid = i.owner#(+) AND 
  213.              NVL(i.type,4) = 4 AND
  214.              (NVL(i.ctime,TO_DATE('01-JAN-00','DD-MON-YY')) < i.itime OR 
  215.               v.expid < NVL(i.expid, 9999))
  216. /
  217. rem current user's view
  218. drop view exuvewu;
  219. CREATE VIEW exuvewu AS
  220.        SELECT *    FROM exuvew WHERE vownerid = UID
  221. /
  222. grant select on exuvewu to public;
  223.  
  224. rem all synonyms
  225. drop view exusyn;
  226. CREATE VIEW exusyn (synnam, syntab, tabown, tabnode,
  227.                 public$, synown, synownid, syntime) AS
  228.        SELECT o$.name, s$.name, s$.owner, s$.node,
  229.             DECODE(o$.owner#, 1, 1, 0),
  230.              uo$.name, o$.owner#, TO_CHAR(o$.ctime, 'YYMMDDHH24MISS')
  231.        FROM sys.obj$ o$, sys.syn$ s$, sys.user$ us$, sys.user$ uo$
  232.        WHERE s$.obj# = o$.obj# AND o$.owner# = uo$.user# AND
  233.          s$.owner = us$.name(+)
  234. /
  235. rem synonyms for incremental export: new or last export not valid
  236. drop view exusyni;
  237. CREATE VIEW exusyni AS 
  238.        SELECT s.* FROM exusyn s, incexp i, incvid v
  239.        WHERE s.synnam = i.name(+) AND s.synownid = i.owner#(+) AND 
  240.              NVL(i.type,5) = 5 AND NVL(i.expid,9999) > v.expid
  241. /         
  242. rem synonyms for cumulative export: new, last export was inc or not valid
  243. drop view exusync;
  244. CREATE VIEW exusync AS 
  245.        SELECT s.* FROM exusyn s, incexp i, incvid v
  246.        WHERE  s.synnam  = i.name(+) AND s.synownid = i.owner#(+) AND 
  247.               NVL(i.type,5) = 5 AND
  248.           (NVL(i.ctime,TO_DATE('01-JAN-00','DD-MON-YY')) < i.itime OR 
  249.                NVL(i.expid,9999) > v.expid)
  250. /
  251. rem user's synnonyms
  252. drop view exusynu;
  253. CREATE VIEW exusynu AS
  254.        SELECT * FROM exusyn WHERE synownid = UID
  255. /
  256. grant select on exusynu to public;
  257.  
  258. rem clustered tables' columns
  259. drop view exucco;
  260. CREATE VIEW exucco(tname, towner, townerid, cluster$, tcolnam, seq) AS
  261.        SELECT t$.name, u$.name, t$.owner#, c$.name, tc$.name, cc$.col#
  262.        FROM sys.obj$ t$, sys.tab$ tab$, sys.obj$ c$,
  263.         sys.col$ tc$, sys.col$ cc$, sys.user$ u$
  264.        WHERE t$.type = 2 AND t$.obj# = tab$.obj# AND
  265.            tab$.clu# = cc$.obj# AND tab$.obj# = tc$.obj# AND 
  266.              tab$.clu# = c$.obj# AND 
  267.              cc$.segcol# = tc$.segcol# AND t$.owner# = u$.user#
  268. /
  269. rem current user's clustered tables' columns
  270. drop view exuccou;
  271. CREATE VIEW exuccou AS
  272.        SELECT * FROM exucco WHERE townerid = UID
  273. /
  274. grant select on exuccou to public;
  275.  
  276. rem all clusters
  277. drop view exuclu;
  278. CREATE VIEW exuclu (objid, owner, ownerid, name, tblspace, size$, fileno,
  279.                 blockno, mtime, pctfree$, pctused$, initrans, maxtrans) AS
  280.        SELECT o$.obj#, u$.name, o$.owner#, o$.name, ts$.name, 
  281.           NVL(c$.size$, -1), c$.file#, c$.block#, o$.mtime, c$.pctfree$, 
  282.               c$.pctused$, c$.initrans, c$.maxtrans
  283.        FROM sys.obj$ o$, sys.clu$ c$, sys.ts$ ts$, sys.user$ u$
  284.        WHERE o$.obj# = c$.obj# AND c$.ts# = ts$.ts# AND o$.owner# = u$.user#
  285. /
  286. rem clusters for incremental export: new or last export invalid
  287. rem altered cluster is not exported because this would require exporting all
  288. rem tables in it.
  289. drop view exuclui;
  290. CREATE VIEW exuclui AS 
  291.        SELECT c.* FROM exuclu c,incexp i, incvid v
  292.        WHERE c.name  = i.name(+) AND c.ownerid = i.owner#(+) AND
  293.          NVL(i.expid,9999) > v.expid
  294. /         
  295. rem clusters for cumulative export: last export was inc or new
  296. rem altered cluster is not exported because this would require exporting all
  297. rem tables in it.
  298. drop view exucluc;
  299. CREATE VIEW exucluc AS 
  300.        SELECT c.* FROM exuclu c,incexp i, incvid v
  301.        WHERE c.name = i.name(+) AND c.ownerid = i.owner#(+) AND 
  302.              NVL(i.type,3) = 3 AND
  303.           (i.itime > NVL(i.ctime,TO_DATE('01-JAN-00','DD-MON-YY'))
  304.              OR NVL(i.expid,9999) > v.expid)
  305. /
  306. rem current user's clusters
  307. drop view exucluu;
  308. CREATE VIEW exucluu AS
  309.        SELECT * FROM exuclu WHERE ownerid = UID
  310. /
  311. grant select on exucluu to public;
  312.  
  313. rem all storage parameters
  314. drop view exusto;
  315. CREATE VIEW exusto (ownerid, fileno, blockno, iniext, sext, minext,
  316.                     maxext, pctinc, blocks) AS
  317.        SELECT user#, file#, block#, iniexts, extsize, minexts, maxexts, 
  318.               extpct, blocks
  319.        FROM sys.seg$
  320.  
  321. rem storage parameters for current user's segments
  322. drop view exustou;
  323. CREATE VIEW exustou AS
  324.        SELECT * FROM exusto WHERE ownerid = UID
  325. /
  326. grant select on exustou to public;
  327.  
  328. rem all tablespaces
  329. drop view exutbs;
  330. CREATE VIEW exutbs (id, owner, name, isonline, iniext, sext, pctinc,
  331.             minext, maxext) AS
  332.        SELECT ts$.ts#, 'SYSTEM', ts$.name, 
  333.           DECODE(ts$.online$, 1, 'ONLINE', 'OFFLINE'), ts$.dflinit,
  334.              ts$.dflincr, ts$.dflextpct, ts$.dflminext, ts$.dflmaxext
  335.        FROM sys.ts$ ts$ 
  336.        WHERE ts$.online$ in (1, 2) and ts$.ts# != 0
  337. /
  338.  
  339. rem tablespace quotas
  340. drop view exutsq;
  341. CREATE VIEW exutsq(tsname, tsid, uname, maxblocks) AS
  342.        SELECT t$.name, q$.ts#, u$.name, q$.maxblocks
  343.        FROM  sys.ts$ t$, sys.tsq$ q$, sys.user$ u$
  344.        WHERE  q$.user# = u$.user# AND q$.ts# = t$.ts# AND q$.maxblocks != 0
  345. /
  346.  
  347. rem block size
  348. drop view exubsz;
  349. CREATE VIEW exubsz(blocksize) AS
  350.        SELECT ts$.blocksize
  351.        FROM   sys.ts$ ts$
  352. /
  353. grant select on exubsz to public;
  354.  
  355. rem all files
  356. drop view exufil;
  357. CREATE VIEW exufil(fname, fsize, tsid) AS
  358.        SELECT v$.name, f$.blocks, f$.ts#
  359.        FROM   sys.file$ f$, sys.v$dbfile v$
  360.        WHERE  f$.file# = v$.file#
  361. /
  362.  
  363. rem all database links
  364. drop view exulnk;
  365. CREATE VIEW exulnk (owner, ownerid, name, user$, passwd, host, public$) AS
  366.        SELECT DECODE(l$.owner#, 1, 'SYSTEM', u$.name), l$.owner#, l$.name, 
  367.               l$.userid, l$.password, l$.host, DECODE(l$.owner#, 1, 1, 0)
  368.        FROM sys.user$ u$, sys.link$ l$
  369.        WHERE u$.user# = l$.owner#
  370. /
  371. drop view exulnku;
  372. CREATE VIEW exulnku AS                /* current user's database links */
  373.        SELECT * FROM exulnk WHERE ownerid = UID
  374. /
  375. grant select on exulnku to public;
  376.  
  377. rem all rollback segments
  378. drop view exursg;
  379. CREATE VIEW exursg (owner, name, space$, fileno , blockno, minext, public$) AS 
  380.        SELECT 'SYSTEM', r$.name, ts$.name, r$.file#, r$.block#, s$.minexts,
  381.              DECODE(r$.user#, 1, 1, 0)
  382.        FROM sys.ts$ ts$, sys.undo$ r$, sys.seg$ s$
  383.        WHERE r$.status$ != 1 AND r$.file# = s$.file# AND r$.block# = s$.block#
  384.              AND s$.ts# = ts$.ts#
  385. /
  386.  
  387. rem info on deleted object
  388. drop view exudel;
  389. CREATE VIEW exudel (owner, name, type, type#) AS
  390.        SELECT u$.name, i$.name, DECODE(i$.type, 2, 'TABLE', 3, 
  391.               'CLUSTER', 4, 'VIEW', 5, 'SYNONYM'), i$.type
  392.        FROM sys.incexp i$, sys.user$ u$
  393.        WHERE i$.owner# = u$.user# AND
  394.              (i$.owner#, i$.name, i$.type) 
  395.              NOT IN (SELECT o$.owner#, o$.name, o$.type 
  396.              FROM   sys.obj$ o$
  397.             )
  398. /
  399.  
  400. rem info on sequence number
  401. drop view exuseq;
  402. CREATE VIEW exuseq (owner, ownerid, name, objid, curval, minval, maxval, 
  403.             incr, cache, cycle, order$, audt) AS
  404.        SELECT u.name, u.user#, o.name, o.obj#, s.highwater, s.minvalue, 
  405.           s.maxvalue, s.increment$, s.cache, s.cycle, s.order$, s.audit$
  406.        FROM sys.obj$ o, sys.user$ u, sys.seq$ s
  407.        WHERE o.obj# = s.obj# AND o.owner# = u.user#
  408. /
  409. drop view exusequ;
  410. CREATE VIEW exusequ AS 
  411.        SELECT * FROM sys.exuseq WHERE UID = ownerid
  412. /
  413. grant select on sys.exusequ to public;
  414.  
  415. rem contraints on table
  416. drop view exucon;
  417. CREATE VIEW exucon (objid, owner, ownerid, tname, type, cname, cno, condition,
  418.                     condlength) AS
  419.        SELECT o.obj#, u.name, c.owner#, o.name, cd.type, 
  420.           DECODE(SUBSTR(c.name,1,5), 'SYS_C', '', NVL(c.name, '')),
  421.               c.con#, cd.condition, cd.condlength
  422.        FROM sys.obj$ o, sys.user$ u, sys.con$ c, sys.cdef$ cd
  423.        WHERE u.user# = c.owner# AND o.obj# = cd.obj# AND cd.con# = c.con#
  424. /
  425. drop view exuconu;
  426. CREATE VIEW exuconu AS 
  427.        SELECT * FROM sys.exucon WHERE UID = ownerid
  428. /
  429. grant select on sys.exuconu to public;
  430.  
  431. rem referential constraints
  432. drop view exuref;
  433. CREATE VIEW exuref (objid, owner, ownerid, tname, rowner, rtname, cname, cno,
  434.                 rcno) AS
  435.        SELECT o.obj#, u.name, c.owner#, o.name, ru.name, ro.name, 
  436.               DECODE(SUBSTR(c.name, 1, 5), 'SYS_C', '', NVL(c.name, '')),
  437.           c.con#, cd.rcon#
  438.        FROM sys.user$ u, sys.user$ ru, sys.obj$ o, sys.obj$ ro, 
  439.             sys.con$ c, sys.cdef$ cd
  440.        WHERE u.user# = c.owner# AND o.obj# = cd.obj# AND ro.obj# = cd.robj# AND
  441.              cd.con# = c.con# AND cd.type = 4 AND ru.user# = ro.owner#
  442. /
  443. drop view exurefu;
  444. CREATE VIEW exurefu AS SELECT * FROM sys.exuref WHERE UID = ownerid
  445. /
  446. grant select on sys.exurefu to public;
  447. rem referential constraints for incremental and cumulative export
  448. rem for tables just exported, i.expid will be greater than v.expid
  449. rem as v.expid is incremented only at the end of the incremental export
  450. rem but i.expid is incremented when the table is exported.
  451. rem USED ONLY WHEN REOCRD = YES
  452. drop view exurefic;
  453. CREATE VIEW exurefic AS
  454.        SELECT * FROM sys.exuref 
  455.        WHERE (ownerid, tname) in 
  456.              (SELECT i.owner#, i.name 
  457.               FROM sys.incexp i, sys.incvid v
  458.               WHERE i.expid > v.expid AND i.type = 2)
  459. /
  460. rem referentail constraints for incremental export
  461. rem exutabi will return the correct table name because RECORD = NO
  462. drop view exurefi;
  463. CREATE VIEW exurefi AS
  464.        SELECT * FROM sys.exuref
  465.        WHERE (ownerid, tname) in (SELECT ownerid, name FROM sys.exutabi)
  466. /
  467. rem referentail constraints for cumulative export, assuming
  468. rem exutabc will return the correct table name because RECORD = NO
  469. drop view exurefc;
  470. CREATE VIEW exurefc AS
  471.        SELECT * FROM sys.exuref
  472.        WHERE (ownerid, tname) in (SELECT ownerid, name FROM sys.exutabc)
  473. /
  474.  
  475. rem contraint column list
  476. drop view exuccl;
  477. CREATE VIEW exuccl (ownerid, cno, colname, colno) AS
  478.        SELECT o.owner#, cc.con#, c.name, cc.pos#
  479.        FROM sys.obj$ o, sys.col$ c, sys.ccol$ cc
  480.        WHERE o.obj# = cc.obj# AND c.obj# = cc.obj# AND cc.col# = c.col#
  481. /
  482. drop view exucclu;
  483. CREATE VIEW exucclu AS
  484.        SELECT * FROM sys.exuccl WHERE UID = ownerid
  485. /
  486. grant select on sys.exucclu to public;
  487.  
  488.