Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Reverse engineer tablespaces.

RE: Reverse engineer tablespaces.

From: Robertson Lee - lerobe <lerobe_at_acxiom.co.uk>
Date: Thu, 24 May 2001 00:43:59 -0700
Message-ID: <F001.0030CEA3.20010524002634@fatcity.com>

Similar to the one below. This can be mucked about with so it doesn't prompt.

Regards

Lee

SCRIPT STARTS HERE



set heading off feedback off verify off
clear columns
clear buffer

accept ts_name prompt 'Enter TableSpace Name : '

col ord noprint
col res format a90

spool cr_tblsp.out

select tablespace_name || '1' ord,

      'create tablespace '|| tablespace_name ||' datafile' res from dba_tablespaces
where tablespace_name like upper('&ts_name%') and status <> 'INVALID'
UNION
-- ## get the middle datafiles - need ','
select a.tablespace_name || '3' ord,

      ' '''|| a.file_name ||''' size '||a.bytes ||',' res from dba_data_files a

where a.tablespace_name like upper('&ts_name%')
and   a.status  <> 'INVALID'
and   a.file_id <> (select max(b.file_id)
                   from   dba_data_files b
                   where  b.tablespace_name = a.tablespace_name)
UNION
-- ## get the last datafile row - no ','
select a.tablespace_name || '5' ord,

      ' '''|| a.file_name ||''' size '||a.bytes res from dba_data_files a

where a.tablespace_name like upper('&ts_name%')
and   a.status  <> 'INVALID'
and   a.file_id = (select max(b.file_id)
                   from   dba_data_files b
                   where  b.tablespace_name = a.tablespace_name)
-- finish off
UNION
select tablespace_name || '99' ord,
'default storage(
        initial      '||INITIAL_EXTENT ||'
        next         '||NEXT_EXTENT    ||'
        minextents   '||MIN_EXTENTS    ||'
        maxextents   '||MAX_EXTENTS    ||'
        pctincrease  '||PCT_INCREASE   ||')
/' res
from dba_tablespaces
where tablespace_name like upper('&ts_name%') and status <> 'INVALID'
/

spool off

SCRIPT ENDS HERE


-----Original Message-----
Sent: 23 May 2001 21:30
To: Multiple recipients of list ORACLE-L

I'm not sure if this is what your looking for but take a look:

spool db_structure.txt
select 'create tablespace ' || a.tablespace_name ||  ' datafile ' || '''' || b.file_name || ''''||' size ' || b.bytes/(1024 * 1024) || 'M' || \
' default storage ( initial ??k next ??k pctincrease ? maxextents ?);' from dba_tablespaces a, dba_data_files b where a.tablespace_name = b.tablespace_name;
spool off;
exit;

Roy

>
>So, I need to re-create a database to prepare for migration. The current DB

>is 8.0.6, and I need to create an 8.1.7 copy.  Does anyone have a script to
>reverse engineer the CREATE TABLESPACE commands?  I started working on one,
>but surely I can't be the first to invent the wheel.
>
>TIA,
>Rich Jesse                          System/Database Administrator
>Rich.Jesse_at_qtiworld.com             Quad/Tech International, Sussex, WI USA
>-- 
>Please see the official ORACLE-L FAQ: http://www.orafaq.com
>-- 
>Author: Jesse, Rich
>  INET: Rich.Jesse_at_qtiworld.com
>
>Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
>San Diego, California        -- Public Internet access / Mailing Lists
>--------------------------------------------------------------------
>To REMOVE yourself from this mailing list, send an E-Mail message
>to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
>the message BODY, include a line containing: UNSUB ORACLE-L
>(or the name of mailing list you want to be removed from).  You may
>also send the HELP command for other information (like subscribing).




Roy E. Ferguson II
Intel Sacramento
916-854-1123

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Roy Ferguson
  INET: rferguso_at_level1.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).


The information contained in this communication is
confidential, is intended only for the use of the recipient
named above, and may be legally privileged. If the reader 
of this message is not the intended recipient, you are
hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.  
If you have received this communication in error, please 
re-send this communication to the sender and delete the 
original message or any copy of it from your computer
system.
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Robertson Lee - lerobe
  INET: lerobe_at_acxiom.co.uk

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Thu May 24 2001 - 02:43:59 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US