Como criar Sequence no Oracle de forma "automática".
declare
cnt number;
begin
for r in (select SEQUENCE_NAME from all_sequences where sequence_owner = 'DATABASE') loop
dbms_output.put_line('drop sequence ' || r.Sequence_name || ' ;');
end loop;
end;
declare
cnt number;
begin
for r in (select table_name from all_tables where owner = 'DATABASE' and SUBSTR(table_name,0,2) <> 'DM') loop
dbms_output.put_line('create sequence sec_' || SUBSTR(r.table_name,0,26) || ' minvalue 1 maxvalue 9999999999 start with 1 increment by 1 nocache cycle;');
end loop;
end;
Fonte: Rodrigo Araujo
declare
cnt number;
begin
for r in (select SEQUENCE_NAME from all_sequences where sequence_owner = 'DATABASE') loop
dbms_output.put_line('drop sequence ' || r.Sequence_name || ' ;');
end loop;
end;
declare
cnt number;
begin
for r in (select table_name from all_tables where owner = 'DATABASE' and SUBSTR(table_name,0,2) <> 'DM') loop
dbms_output.put_line('create sequence sec_' || SUBSTR(r.table_name,0,26) || ' minvalue 1 maxvalue 9999999999 start with 1 increment by 1 nocache cycle;');
end loop;
end;
Fonte: Rodrigo Araujo
Nenhum comentário:
Postar um comentário