home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / database / oracle / 1513 < prev    next >
Encoding:
Text File  |  1992-09-08  |  4.1 KB  |  124 lines

  1. Path: sparky!uunet!mcsun!sunic!psinntp!psinntp!dlogics!hermes.dlogics.com!dlm
  2. From: dlm@hermes.dlogics.com
  3. Newsgroups: comp.databases.oracle
  4. Subject: Re: how to compress database and move indexes to different tablespace
  5. Message-ID: <1992Sep5.085244.1304@hermes.dlogics.com>
  6. Date: 5 Sep 92 08:52:44 CST
  7. References: <1992Sep2.100626.1@bbs.mdcbbs.com>
  8. Organization: Datalogics, Inc., Chicago, IL
  9. Lines: 113
  10.  
  11. Recently, suskind@bbs.mdcbbs.com writes:
  12. > I am trying to compress my database. While I am at it I am moving stuff
  13. > into various tablespaces to improve performance and layout. My original
  14. > database has only ONE tablespace "system". My new database will have
  15. > "system", "user", "temp", and "index". I can see how to easily move
  16. > a user's tables into the "user" tablespace by only giving him resource
  17. > in that tablespace and altering his user account so "user" is his default
  18. > tablespace. 
  19. This is a very good idea.  Also, consider creating a ROLLBACK tablespace just
  20. for your rollback segments. And see if you can put each tablespace on a
  21. different device.
  22. > However, how to I move the corrisponding indexes? I have tried using the
  23. > "show" option of IMP to generate a file, but this file is in such a poor
  24. > format I cannot use it without EXTENSIVE editing. Does anybody have a
  25. > utility that will take the file generated by the "show" option and make it
  26. > usable? The format I get is ONLY 80 column records and EVERY line is
  27. > enclosed in double quotes.
  28. Yes, "show" has its problems; you could use the "INDEXFILES=filename"
  29. option which will create usable CREATE statements. You will have to edit this
  30. file carefully to replace the tablespace names. If you are a unix dba then of
  31. course this is easy; otherwise you will have to concoct something.
  32.  
  33. Here's another solution for oracle v6 VMS which can be adapted to anybody's o/s.
  34. It is a SQL script that scans the data dictionary to create another SQL script
  35. which it then executes:
  36. $!    database_integrity.com
  37. $!    d. l. mausner. 17-apr-92.
  38. $!    (c) 1992 datalogics, inc.
  39. $!
  40. $    scratch = f$getjpi("","pid")
  41. $    define /user sys$output T'scratch'.com
  42. $    sqlplus -s / @sys$input
  43. set pages 0 lines 100 verify off feedb off pause off recsep off
  44. column NP format a1 noprint
  45. column TX format a80 word
  46. prompt $    set verify
  47. prompt $    sqlplus -s /
  48.  
  49. rem    be sure only certain special users have DBA privs.
  50.  
  51. select 'revoke dba from ' || username || ';' TX
  52. from sys.dba_users
  53. where dba_priv = 1  and
  54. username not in ('SYS','SYSTEM','PUBLIC','OPS$ORACLE') and
  55. username not in ('OPS$TOPS_SYS','OPS$NSG','OPS$RAS','OPS$MFM') and
  56. username like 'OPS$%'
  57. /
  58.  
  59. rem    be sure temporaries default to TEMP1.
  60.  
  61. select 'alter user ' || username || ' temporary tablespace TEMP1;' TX
  62. from sys.dba_users
  63. where connect_priv = 1 and
  64. temporary_tablespace != 'TEMP1' and
  65. username not in ('SYS','PUBLIC')
  66. /
  67.  
  68. rem    be sure everyone has resources on INDEX1.
  69.  
  70. select 'grant resource on index1 to ' || username || ';' TX
  71. from sys.dba_users
  72. where connect_priv = 1 and
  73. username not in (
  74. select username from sys.dba_ts_quotas where tablespace_name='INDEX1') and
  75. username not in ('SYS','PUBLIC')
  76. /
  77.  
  78. rem    be sure user indexes are stored in INDEX1 tablespace.
  79.  
  80. set termout off
  81. drop table u1indexes
  82. /
  83. set termout on
  84. create table u1indexes (xo, xn, bo, bn, un) as
  85. select owner, index_name, table_owner, table_name, 
  86. decode(uniqueness, 'NONUNIQUE', null, uniqueness)
  87. from sys.dba_indexes
  88. where tablespace_name = 'USER1'
  89. /
  90. select
  91. 'drop index ' || xo || '.' || xn || ';' TX
  92. from u1indexes 
  93. /
  94. select
  95. 'create ' || un || ' index ' || xo || '.' || xn || ' on ' || bo || '.' || bn TX,
  96. xo NP, xn NP, 0 NP
  97. from u1indexes 
  98. union
  99. select 
  100. decode(column_position, 1, '(', ',') || column_name TX,
  101. index_owner NP, index_name NP, column_position NP
  102. from sys.dba_ind_columns
  103. where index_name in (select xn from u1indexes)
  104. union
  105. select 
  106. ') tablespace index1;' TX,
  107. xo NP, xn NP, 999 NP
  108. from u1indexes
  109. order by 2,3,4
  110. /
  111. set termout off
  112. drop table u1indexes
  113. /
  114. set termout on
  115. prompt exit
  116. exit
  117. $    @T'scratch'.com
  118. $    delete T'scratch'.com;*
  119. $    exit
  120. --
  121. Dave Mausner, Senior Consultant / Datalogics Inc / Chicago IL / 312-266-4450
  122. dlm@dlogics.com                                 Motto: Just show me the code
  123.