Re: Generate DDL from a Schema



nickli2000@xxxxxxxxx wrote:
Hi,

I am trying to generate DDL scripts for each table, view and other
indexes under a schema. I tested using DBMS_METADATA package and its
get_ddl procedure. However, I can only output the create table (view,
indexes) statements for all the tables in a schema in one script, not
in each separation script, such as create table table_1.script, create
table table_2.script, etc.
I have hundreds of tables, views, indexes, types and other objects
under one schema. I would appreciate your advice on the issue.

Thanks in advance.

Nick Li


If I understood what you are asking, you will have to create a script which creates your scripts. Something like the following:

set heading off
set pagesize 0
set feedback off
spool create_ddl.sql
SELECT 'spool create_'||object_type||'_'||object_name||'.sql'||chr(10)||
'SELECT dbms_metadata.get_ddl('''||object_type||''','''||object_name||
''','''||owner||''') from dual;'||chr(10)||
'spool off'
FROM dba_objects WHERE owner='SCOTT';
spool off
@create_ddl.sql

The above creates the commands to start spooling to a specific file, then then run the GET_DDL function.

HTH,
Brian


--
===================================================================

Brian Peasland
dba@xxxxxxxxxxxxxxxxxxx
http://www.peasland.net

Remove the "nospam." from the email address to email me.


"I can give it to you cheap, quick, and good.
Now pick two out of the three" - Unknown

--
Posted via a free Usenet account from http://www.teranews.com

.



Relevant Pages

  • Re: WSH in VS.NET 2003?
    ... or will wsh xml include a ... Get the "TechNet Script Center Sample Scripts" ... Other|Useful Scripting Technologies|Saving Data in XML Format ... There is no schema for getting MS. ...
    (microsoft.public.scripting.wsh)
  • Re: Synchronization Wizard weirdness
    ... Using the Oracle Enterprise Manager and Oracle Change Manager packages, ... :> I have a Test Schema in the same database as the Main schema and need to ... Wizard between the Main schema and Test schema -- obviously returned the full ... :> All seems to go well, until the script actually runs. ...
    (comp.databases.oracle.tools)
  • Re: Rebuilding the system schema
    ... a way to rebuild the system schema to get all of the objects back in? ... this a production database? ... This was the system user- logged in as system and ran a script that ... tablespace from your archived redo logs. ...
    (comp.databases.oracle.server)
  • Re: Data Migration
    ... one to compare data. ... I know the schema tool will generate change scripts ... but I don't know if it can generate data change scripts. ... > was hoping there was something out there that would script the dropping on ...
    (microsoft.public.sqlserver.tools)
  • Re: Deleting AD Schema Fields with LDIFDE - Access Denied
    ... "Joe Kaplan" wrote in message ... You should never test schema extensions on a production AD forest. ... The administrator has all possible rights (also "Delete All Child ... >>> If I'm using this script on my new domain, ...
    (microsoft.public.windows.server.active_directory)