user table¸¸ sql script ·Î ¹ÞÀ¸·Á¸é
ÀÛ¼ºÀÚ °ü¸®ÀÚ ÀÛ¼º½Ã°£ 2006-03-07 16:50:44
 

exp¸»°í´Â ÅøÀ» ÀÌ¿ëÇÏ´ø°¡

(OEM,dbamasterµîµî)

Äõ¸®¹®À¸·Î ÀÛ¼ºÇÏ½Ã¸é µÈ´Ù.

-----------------------------

create or replace function create_table( r_owner in

varchar2, r_table_name in varchar2 )

return varchar2

as

starting boolean :=true;

begin

dbms_output.put_line('create table '||r_owner||'.'||r_table_name||'(');

for r in (select column_name, data_type, data_length, data_precision,

data_scale, data_default, nullable

from all_tab_columns

where table_name = upper(r_table_name)

and owner=upper(r_owner)

order by column_id)

loop

if starting then

starting:=false;

else

dbms_output.put_line(',');

end if;



if r.data_type='NUMBER' then

if r.data_scale is null then

dbms_output.put(r.column_name||' NUMBER('||r.data_precision||')');

else

dbms_output.put(r.column_name||'

NUMBER('||r.data_precision||','||r.data_scale||')');

end if;

else if r.data_type = 'DATE' then

dbms_output.put_line(r.column_name||' DATE');

else if instr(r.data_type, 'CHAR') >0 then

dbms_output.put(r.column_name||' '||r.data_type||'('||r.data_length||')');

else

dbms_output.put(r.column_name||' '||r.data_type);

end if;

end if;

end if;

if r.data_default is not null then

dbms_output.put(' DEFAULT '||r.data_default);

end if;

if r.nullable = 'N' then

dbms_output.put(' NOT NULL ');

end if;

end loop;

dbms_output.put_line(' ); ');

return null;

end;

/



select create_table( user, table_name )

from user_tables

where rownum < 5

/



exec null;


¸ñ·Ï | ÀÔ·Â | ¼öÁ¤ | ´äº¯ | »èÁ¦