accept table_name prompt 'Table name: ' accept owner prompt 'Table owner: ' set long 90000 set longchunksize 300 set pagesize 0 set linesize 300 set trimspool on set heading off set verify off set echo off set feedback off spool table_ddl.lst exec DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SEGMENT_ATTRIBUTES',FALSE); exec DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'STORAGE',TRUE); exec DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',TRUE); select dbms_metadata.get_ddl('TABLE',UPPER('&&table_name'),UPPER('&&owner')) from dba_tables where table_name = UPPER('&&table_name'); exit
Minimalistic Oracle contains a collection of practical examples from my encounters with Oracle technologies. When relevant, I also write about other technologies, like Linux or PostgreSQL. Many of the posts starts with "how to" since they derive directly from my own personal experience. My goal is to provide simple examples, so that they can be easily adapted to other situations.
Wednesday, March 26, 2014
How to use the dbms_metadata package to generate DDL for table
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment