脚本可分两部分:
同义词
:synonymcmd:
sqlplus dxsq/teledoone@jnnew @synonymsql
synonymsql:
create table tmp_user_synonym as select create synonym ||synonym_name||chr()||for||chr()||TABLE_OWNER||||TABLE_NAME||chr()||/ text from user_synonyms;
set heading off feedback off termout off
set pagesize
set linesize
set long
col tt format a
spool d:\bat\synonymlog;
select text tt from tmp_user_synonym;
spool off;
drop table tmp_user_synonym;
exit;
大家可以以一反三系列的写法可以参考下面:
drop table tmp_user_sequence;
create table tmp_user_sequence (text varchar());
declare
begin
for tt in (select * from user_sequences) loop
insert into tmp_user_sequence values(prompt);
insert into tmp_user_sequence values(prompt create sequence ||ttSEQUENCE_NAME);
insert into tmp_user_sequence values(prompt);
insert into tmp_user_sequence values(create sequence || || ttSEQUENCE_NAME);
insert into tmp_user_sequence values(minvalue || || ttMIN_VALUE );
insert into tmp_user_sequence values(MAXVALUE || || ttMAX_VALUE);
insert into tmp_user_sequence values(start with || ||ttLAST_NUMBER);
insert into tmp_user_sequence values(increment by || || ttINCREMENT_BY);
insert into tmp_user_sequence values(cache || || to_char(ttCACHE_SIZE));
if ttCYCLE_FLAG=Y then
insert into tmp_user_sequence values(cycle);
end if;
if ttORDER_FLAG=Y then
insert into tmp_user_sequence values(order);
end if;
insert into tmp_user_sequence values(/);
insert into tmp_user_sequence values();
end loop;
commit;
end;
/
set heading off feedback off termout off;
column text format A;
spool d:\bat\user_sequenceslog
select text from tmp_user_sequence;
spool off;
exit;