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: Scripts for creating Tables/schema's

RE: Scripts for creating Tables/schema's

From: Stephen Lee <slee_at_dollar.com>
Date: Mon, 28 Oct 2002 07:48:50 -0800
Message-ID: <F001.004F52F6.20021028074850@fatcity.com>

To recreate an existing schema, export the schema with rows=n. Then run import with show=y and send the output to a file. On metalink, you can get the following awk script to parse the file and send the output to another file. You will probably have to hand edit the final file to fix some line formatting errors (like a line break where there should not be).

  awk ' BEGIN { prev=";" }

/ \"CREATE / { N=1; }
/ \"ALTER / { N=1; }
/ \"ANALYZE / { N=1; }
/ \"GRANT / { N=1; }
/ \"COMMENT / { N=1; }
/ \"AUDIT / { N=1; }

        N==1 { printf "\n/\n\n"; N++ }
        /\"$/ { prev=""
              if (N==0) next;
              s=index( $0, "\"" );
                      if ( s!=0 ) {
                    printf "%s",substr( $0,s+1,length( substr($0,s+1))-1 )
                    prev=substr($0,length($0)-1,1 );
              }
              if (length($0)<78) printf( "\n" );
              }'


You might want adjust the storage parameters too. If you are using vi (Remember: vi is your friend) you can do this quickly with something like:

:%s/INITIAL [0-9][0-9]*/ INITIAL 1M/

Of course, all this assumes you are on a Unix box.

 i wanted a script which contains the create table/schema's for a existing database.
How to get this script ? any utitlity or which option to be selected for achieving this after i install Oralce ?

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Stephen Lee
  INET: slee_at_dollar.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
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 Mon Oct 28 2002 - 09:48:50 CST

Original text of this message

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