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

Home -> Community -> Usenet -> c.d.o.server -> Re: Easy question

Re: Easy question

From: Brian Ewins <Brian.Ewins_at_gssec.bt.co.uk>
Date: 1997/06/10
Message-ID: <339D86DB.2BF4@gssec.bt.co.uk>

Detlev Goebel wrote:
>
> Hugo Juan Jordan wrote:
> >
> > In order to document the structure of a database, they have asked me to
> > obtain a text file with all the SQL statements needed to build the same
> > database that I am running in a Oracle server 7.3.. I'm sure it must be
> > very easy to obtain, but I have no idea.
> > Any suggestions?
> >
> > I'm very sorry to ask silly questions, but I'm still very far from really
> > good ones.
> >
> > Thanks in advance.
> >
> > Hugo Juan
>
> Hugo,
>
> I never heard of silly questions did you?
> Your requirements are not trivial at all. You have to look up several
> system views to get your information :
> sys.all_tables - to get all information about tables like storage and
> tablespace where they reside.
> sys.dba_tab_columns - for al columns of those tables (names, datatype,
> length and default values).
> sys.all_indexes - for indexes on those tables.
> sys.dba_index_columns - for the columns of those indexes.
> sys.all_constraints - for the constraints on those tables.
> sys.all_views - for the views.
>
> Maybe the tablespaces, the user informations, datafiles and so on.
>
> if you'll write scripts take care about it.
>
> Otherwise I'm sure there are some tools anywhere in the net to do this.
> Perhaps anyone else can provide some URL's.

Okey dokey - while other's suggestions of tools to recreate the entire DB are useful, http://www.oramag.com (Oracle Magazine) has a script which, when run as sys or system, can do this for a single table. (look in the top tips or codebase sections at that site). Here's how its done for indexes: (I wrote this: no warranty!)


I find this script useful when someone's being adding indexes to a table during development and they're going to be dropped for a data load - I don't need to rely on knowing where all the index creation scripts were at (a couple of times they havent even existed).

Anyway, its trivial to combine the gentab script (suitably hacked to be usable by users) and genidx above, to recreate all tables and indexes.

The awkward bit arises when you have constraints which were created 'using index'... these indexes shouldn't be dropped, and the stuff above should instead go towards an 'alter table enable constraint <foo> using index...' statement.

        Hope this helped.

-- 
****====----                                              Brian Ewins. 
Fax: (44) 141 220 6100                          Tel: (44) 141 220 6121
 "It's time we face reality, my friends...
      We're not exactly rocket scientists." --Gary Larson ----====****
Received on Tue Jun 10 1997 - 00:00:00 CDT

Original text of this message

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