Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: table creation
X-Sun-Data-Type: text X-Sun-Data-Description: text X-Sun-Data-Name: text X-Sun-Charset: us-ascii X-Sun-Content-Lines: 15
Dave:
a long time ago i needed to replicate some production tables on a very small database. because the database was so small (due to hardware requirements) i could not use the exp and imp utilities. to get around this i used the scripts that are attached to this message. one is just a sql script and one is a shell script that executes the sql script. its output should be a create statement for a given table. i haven't used it in a while so check out its results to make sure their accurrate.
good luck
david wolcott
davidw_at_imagin1.com
X-Sun-Data-Type: default X-Sun-Data-Description: default X-Sun-Data-Name: tab_create.sql X-Sun-Charset: us-ascii X-Sun-Content-Lines: 63
set pages 0
col maxid new_value maxid noprint
select max(column_id) maxid from dba_tab_columns where owner='&&1' AND table_name = '&&2' ;
set term off
set echo off
set concat +
spool &&1+_&&2.sql
set concat .
set feedback off
set heading off
set pagesize 0
set ver off
select 'create ' ||
' table ' ||table_name || '('
from sys.dba_tables where owner= '&&1' and table_name = '&&2'
/
select column_name||' '||data_type||' '||decode(nullable,'N',' not null',null)
||decode(data_type,'VARCHAR2','(','CHAR','(',null)
||decode(data_type,'VARCHAR2',data_length,'CHAR',data_length,null)
||decode(data_type,'VARCHAR2',')','CHAR',')',null)
||decode(data_scale,null,null,'(')
||decode(data_precision,null,null,data_precision)
||decode(data_scale,null,null,0,null,',')
||decode(data_scale,null,null,0,null,data_scale)
||decode(data_scale,null,null,')')
select 'REM *********************** NEW TABLE ********************'FROM DUAL;
X-Sun-Data-Type: msdos-executable X-Sun-Data-Description: msdos-executable X-Sun-Data-Name: create_test1_tables.exe X-Sun-Charset: us-ascii X-Sun-Content-Lines: 1
sqlplus sys/password @tab_create DAVIDB ACCTBALS Received on Sun Mar 19 1995 - 18:41:34 CST