Showing posts with label scripts. Show all posts
Showing posts with label scripts. Show all posts

Monday, April 06, 2009

Generate exp parfile for table mode export

We have exp job based on the schema. Now we want to use table mode exp. The following script can thus be used to generate parfile. Every month we have release, which may add new tables. So using script to generate the parfile could be handy. It is obviously possible to modify the query to generate the table list based on some condition.



spool export.par
set echo off heading off feed off
set linesize 200
pro userid=/
pro buffer=52428800
pro compress=n
pro constraints=y
pro indexes=y
pro grants=y
pro direct=Y
pro consistent=n
pro statistics=none
pro tables=(
select decode(rownum, 1, ' ', ',') ||
owner || '.' || table_name
from dba_tables where owner = 'DENIS';
pro )
spool off



  

The generated parfile looks like:


userid=/
buffer=52428800
compress=n
constraints=y
indexes=y
grants=y
direct=Y
consistent=n
statistics=none
tables=(

DENIS.BM
,DENIS.X
,DENIS.MY_LOAD_METRICS
,DENIS.T1
,DENIS.A
,DENIS.BI
,DENIS.T2
,DENIS.T14
,DENIS.PLAN_TABLE
)

Wednesday, June 25, 2008

Get DDL of all tables and indexes in a Schema

DBMS_METADATA package can be conveniently used to get the DDL of all tables and indexes in a schema. The sample syntax is as follows:



set pagesize 0
set long 90000
set feedback off
set echo off
spool ddl.txt
SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name, 'MY_SCHEMA') || '/'
FROM dba_tables u
where owner='MY_SCHEMA';


SELECT DBMS_METADATA.GET_DDL('INDEX',u.index_name, 'MY_SCHEMA') || '/'
FROM dba_INDEXES u
where owner='MY_SCHEMA';
spool off;