Database BACKUP

Posted on 2003-10-22
Last Modified: 2007-12-19

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

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!

Question by:iit
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

Accepted Solution

Danielzt earned 25 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


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 :
LVL 48

Expert Comment

ID: 9604750
Export, Import is a good choice.
for other possibility.

Author Comment

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

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!
Technology Partners: 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!


Expert Comment

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? :-)

Author Comment

ID: 9717132
Kong: Thank you for the comments.

Do you have any such sample scripts?

Assisted Solution

Kong earned 25 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:

SELECT 'SELECT dbms_metadata.get_ddl(''' || object_type
       || ''', ''' || object_name || ''') FROM DUAL;'
  FROM user_objects

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.



Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

710 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