Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to generate script from database 1

Status
Not open for further replies.

gulshan

Programmer
Jun 21, 2000
1
0
0
US
i have a complete database, but script used for generating that database is not available with me.(for particular user).<br>So please lem'me know how to generate the script from database. <br>One way which I know is using reverse engineering in ERwin and then generate the sql script from that. But I don't want to use any ERwin (third party) tool.<br>If you know any methos then lem'me know at <A HREF="mailto:Gulshan.wadhwa@engineer.com">Gulshan.wadhwa@engineer.com</A><br><A HREF="mailto:gulshanwadhwa@engineer.com">gulshanwadhwa@engineer.com</A><br><br>Thanx,
 
You can generate table and index create statements from an Oracle export by importing using the indexfile parameter.&nbsp;&nbsp;That might be enough for your needs.
 
I didn't think about this until I saw Karl's post but exp can do the whole thing, tables, indexes, constraints, tablespaces, clusters. I think the parameter is rows=no.<br> <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
What you can do is, Export the Full Database and then you can use SHOW and INDEXFILE option to generate a script file for the Tables and Indexes in all the users.&nbsp;&nbsp;In case you want the script of a specified user, then specify the username in the options while IMPort.&nbsp;&nbsp;With ROWS=No, you will NOT get the script to INSERT the records in the tables.
 
How can I also re-create database triggers at the same time as they apply to the table being replicated/copied?
 
exp does triggers as well. <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
I am trying to do a similar thing, recreate a database from a full export of an existing one. However, I seem to need the users setup in the new one prior to importing? This is a problem as the roles, and system & object rights of each user are very longwinded.

Is there a way of either setting the users up correctly from the export file, or generating a script from the old database to do this prior to importing?

Thanks for your help
 
patr1q.

As colleagues pointed out above &quot;export database&quot; will provide you with all you need. The <database>.dmp file produced is a binary file. If you are working on UNIX you can easily extract the user creation and grant section to ensure that the import will work. You can try the following option that I normally use. In the example below test.dmp is the full export for a database called &quot;test&quot;. I use UNIX utility egrep with option '-a' which will treat the binary dump file as a text file

Code:
cat test.dmp | egrep -a -i 'create user|grant ' > abc.sql

cat abc.sql

CREATE USER &quot;SCOTT&quot; IDENTIFIED BY VALUES 'F894844C34402B67' DEFAULT TABLESPACE &quot;DATA&quot; TEMPORARY TABLESPACE &quot;TEMPTS1&quot;
CREATE USER &quot;IBMS&quot; IDENTIFIED BY VALUES 'B56BF24F357A5318' DEFAULT TABLESPACE &quot;BSS_DATA&quot; TEMPORARY TABLESPACE &quot;TEMP&quot;
CREATE USER &quot;BSS&quot; IDENTIFIED BY VALUES '8905450AC4CF40B7' DEFAULT TABLESPACE &quot;BSS_DATA&quot; TEMPORARY TABLESPACE &quot;TEMP&quot;
CREATE USER &quot;ODYSSEY&quot; IDENTIFIED BY VALUES '5BF8317FFD7F22D4' DEFAULT TABLESPACE &quot;ODYSSEY_DATA&quot; TEMPORARY TABLESPACE &quot;TEMP&quot;
CREATE USER &quot;RATINGS&quot; IDENTIFIED BY VALUES 'A058D77389DD3631' DEFAULT TABLESPACE &quot;RATINGS_DATA&quot; TEMPORARY TABLESPACE &quot;TEMP&quot;
CREATE USER &quot;WORKFLOW&quot; IDENTIFIED BY VALUES 'E9C4850247F1DFC4' DEFAULT TABLESPACE &quot;WORKFLOW_DATA&quot; TEMPORARY TABLESPACE &quot;TEMP&quot;
CREATE USER &quot;USER1&quot; IDENTIFIED BY VALUES 'BBE7786A584F9103' DEFAULT TABLESPACE &quot;MAG_DATA&quot; TEMPORARY TABLESPACE &quot;TEMP&quot;
CREATE USER &quot;USER2&quot; IDENTIFIED BY VALUES '1718E5DBB8F89784' DEFAULT TABLESPACE &quot;MAG_DATA&quot; TEMPORARY TABLESPACE &quot;TEMP&quot;
CREATE USER &quot;USER3&quot; IDENTIFIED BY VALUES '94152F9F5B35B103' DEFAULT TABLESPACE &quot;MAG_DATA&quot; TEMPORARY TABLESPACE &quot;TEMP&quot;
CREATE USER &quot;USER4&quot; IDENTIFIED BY VALUES '2907B1BFA9DA5091' DEFAULT TABLESPACE &quot;MAG_DATA&quot; TEMPORARY TABLESPACE &quot;TEMP&quot;
CREATE USER &quot;USER5&quot; IDENTIFIED BY VALUES '6E97FCEA92BAA4CB' DEFAULT TABLESPACE &quot;MAG_DATA&quot; TEMPORARY TABLESPACE &quot;TEMP&quot;
CREATE USER &quot;SSR9&quot; IDENTIFIED BY VALUES '273D996ED66AD4EC' DEFAULT TABLESPACE &quot;BSS_DATA&quot; TEMPORARY TABLESPACE &quot;TEMP&quot;
CREATE USER &quot;TOAD&quot; IDENTIFIED BY VALUES '666554011D812613' DEFAULT TABLESPACE &quot;TOOLS&quot; TEMPORARY TABLESPACE &quot;TEMPTS1&quot;
CREATE USER &quot;DUMMY&quot; IDENTIFIED BY VALUES '933E4BFA48C26E04' DEFAULT TABLESPACE &quot;DATA&quot; TEMPORARY TABLESPACE &quot;TEMPTS1&quot;
GRANT CREATE USER TO &quot;SYS&quot;
GRANT CREATE USER TO &quot;WKSYS&quot;
GRANT UNLIMITED TABLESPACE TO &quot;SYSTEM&quot; WITH ADMIN OPTION
GRANT UNLIMITED TABLESPACE TO &quot;OUTLN&quot;
GRANT EXECUTE ANY PROCEDURE TO &quot;OUTLN&quot;
GRANT SELECT ANY TABLE TO &quot;SYS&quot; WITH ADMIN OPTION
GRANT CREATE SESSION TO &quot;RECOVERY_CATALOG_OWNER&quot;
GRANT ALTER SESSION TO &quot;RECOVERY_CATALOG_OWNER&quot;
GRANT CREATE TABLE TO &quot;RECOVERY_CATALOG_OWNER&quot;
GRANT CREATE CLUSTER TO &quot;RECOVERY_CATALOG_OWNER&quot;
GRANT CREATE SYNONYM TO &quot;RECOVERY_CATALOG_OWNER&quot;
GRANT CREATE VIEW TO &quot;RECOVERY_CATALOG_OWNER&quot;
GRANT CREATE SEQUENCE TO &quot;RECOVERY_CATALOG_OWNER&quot;
GRANT CREATE DATABASE LINK TO &quot;RECOVERY_CATALOG_OWNER&quot;


Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top