?
Solved

Database BACKUP

Posted on 2003-10-22
6
Medium Priority
?
713 Views
Last Modified: 2007-12-19
Hello-

I want to backup my database, including tables, constraints, procedures,packages, primary keys, indexes etc.

I have found DBMS_METADATA.GET_DEPENDENT_DDL() function helpful

I also found this link helpful
http://www.dba-oracle.com/art_builder_get_schema_syntax.htm

In the section "Issues with dbms_metadata"


When you have foreign keys (“references” constraints), it would be nice to punch the table DDL in their proper order for re-loading into another database.  If you do not order the table, a table may be added that references another table that has not yet been added.  Making this change would involve adding a WHERE clause that queries dba_constraints and dba_cons_columns to determine the proper table order.

How do I use dba_constraints and dba_cons_columns to retrieve the table in the proper order?
Any example would be highly appreciated.

thank you very much for all your help!

0
Comment
Question by:iit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 8

Accepted Solution

by:
Danielzt earned 100 total points
ID: 9603745

if you really want to backup my database, including tables, constraints, procedures,packages, primary keys, indexes etc.

The export/import is easy way for you. the export file, usually called dump file, includes all the DDLs and data for all the database objects.

export/import are two utility shipped with oracle. In oracle 8i,they are exp.exe and imp.exe.

in the command prompt:
assume you work on windows(same as on unix)
C>exp help=y

usually, you have 3 ways to export data from the database.

FULL,OWNER and Table

examples:

to export the whole database:
(You need to have EXP_FULL_DATABASE privilege. )
C:>exp system/manager@service_name  full=y file=ABCD.dmp log=ABCD_exp.log

to export a schema(all the database objects belong to the user):

C:>exp scott/tiger@service_name  file=ABCD.dmp owner=SCOTT log=ABCD_exp.log

to export tables:

C:>exp scott/tiger@service_name  file=ABCD.dmp tables=(exp,dept) log=ABCD_exp.log

if you do not want the records in the tables, you can use rows=N to do that.

For more details, see :
http://download-west.oracle.com/docs/cd/A87860_01/doc/server.817/a76955/toc.htm
0
 
LVL 48

Expert Comment

by:schwertner
ID: 9604750
Export, Import is a good choice.
see
http://oldlook.experts-exchange.com/Databases/Oracle/Q_20774214.html
for other possibility.
0
 

Author Comment

by:iit
ID: 9608670
thank you for the comments.

I agree exp/imp are great tools to backup. I should have posted my clearly like this,

I want to *extract ddl* that creates my whole database with package, procedures, tables etc. For this dbms_metadata.get_ddl is a great tool. But, as discussed at this link
http://www.dba-oracle.com/art_builder_get_schema_syntax.htm

there might be problems creating the db when tables have referential constraints, unless the parent tables in the relationship are created first.  It is discussed in the section "Issues with dbms_metadata"
My question is
How do I use dba_constraints and dba_cons_columns to retrieve the tables in the proper order?

sorry for the confusion.

thank you very much for your comments!
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:Kong
ID: 9612383
You could write a convoluted query/sub-program to do this but the problem will be with circular referencing tables.

Make your life easier, create all tables first or run the resultant scripts from get_ddl a few times ignoring the ORA-00955 errors. Oracle does it all the time - ever seen the output of running catalog.sql and catproc.sql? :-)
0
 

Author Comment

by:iit
ID: 9717132
Kong: Thank you for the comments.

Do you have any such sample scripts?
0
 
LVL 2

Assisted Solution

by:Kong
Kong earned 100 total points
ID: 9718502
iit, use dbms_metadata.get_ddl function to get the ddl, you can generate the scripts to call the function eg:

SET PAGES 0 HEAD OFF LINES 200 LONG 30000
SELECT 'SELECT dbms_metadata.get_ddl(''' || object_type
       || ''', ''' || object_name || ''') FROM DUAL;'
  FROM user_objects
 WHERE object_type NOT LIKE '%PARTITION';

Then run the results. RE: referencial constraints - don't bother writing a script that creates tables in the right order, no script will handle circular dependencies.

HTH

K
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question