Extracting DDLs from Oracle

chncaesar發表於2013-08-20

1. DBMS_METADATA

This example extracts DDLs of every table and index from scott, run it in sqlplus:

 set pagesize 0    ---Does not display column names.

set long 90000    ---9000 bytes of cache in local machine for LONG datatype

set feedback off  --Does not display messages like "PL/SQL procedure successfully completed"

set echo off         --START command does not list each command in a script. as       --the command is executed.

spool scott_schema.sql --Spool to a file

connect scott/tiger@orcl;   --Connecting as scott

SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name) FROM USER_TABLES u;

SELECT DBMS_METADATA.GET_DDL('INDEX',u.index_name) FROM USER_INDEXES u;

spool off;           --Turn off spool

2. exp command.
exp scott/123456@pdborcl grants=N indexes=Y triggers=N record=N Statistics=None wner=scott 

Creates expdat.dmp in current directory, you need to manually edit the file to eliminate useless content.

3. Database Export of SQL Developer.
Select "Tools" --&gt "Database Export", and a wizard will guide you through the whole process. It gives you the choice to :
1. Export the storage parameters
2. Export the data
3. Select the objects (tables, indexes, views, MVs, db links, packages, procedures) to export.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/638844/viewspace-768902/,如需轉載,請註明出處,否則將追究法律責任。

相關文章