【SQL】【迁移】写了一个简单的sequence迁移脚本

脚本如下,因为sequence分缓存和不缓存数据,所以这里分两个SQL来实现,这个脚本在我手工迁移数据过程中起到了重要的作用。
prompt migrate sequences
set lin 140
set head off
spool migrate_seq.sql
select
'create sequence '|| SEQUENCE_NAME || ' start with '||LAST_NUMBER||' maxvalue '||MAX_VALUE||' minvalue '||MIN_VALUE||' increment by '||INCREMENT_BY||' cache '||CACHE_SIZE||' '||decode(CYCLE_FLAG,'N','NOCYCLE','CYCLE')||' '||decode(ORDER_FLAG,'N','NOORDER','ORDER')||' ;' "-- create seq scripts"
from user_sequences@dblinktosec where CACHE_SIZE != 0;

select
'create sequence '|| SEQUENCE_NAME || ' start with '||LAST_NUMBER||' maxvalue '||MAX_VALUE||' minvalue '||MIN_VALUE||' increment by '||INCREMENT_BY||' NOCACHE '||decode(CYCLE_FLAG,'N','NOCYCLE','CYCLE')||' '||decode(ORDER_FLAG,'N','NOORDER','ORDER')||' ;' "-- create seq scripts"
from user_sequences@dblinktosec where CACHE_SIZE = 0;

spool off
@@migrate_seq.sql

-- The End --
请使用浏览器的分享功能分享到微信等