oracle為資料庫每張表建立序列

livedba發表於2011-09-19
oracle為資料庫每張表建立序列

[@more@]

create or replace procedure CREATE_SEQ IS
v_str VARCHAR2(500);

cursor ALLTABLES IS
SELECT s.table_name FROM all_tables s
WHERE s.owner='TEST' AND (s.table_name LIKE 'BASE_%' OR s.table_name LIKE 'BD_%' OR s.table_name LIKE 'CS_%' OR s.table_name LIKE 'ES_%' OR s.table_name LIKE 'FM_%');
begin
FOR allTab IN ALLTABLES LOOP
EXECUTE IMMEDIATE 'create sequence SEQ_'||allTab.Table_Name||
' minvalue 1'||
' maxvalue 999999999999999'||
' start with 1000'||
' increment by 1'||
' cache 20';
END LOOP;
end CREATE_SEQ;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25261409/viewspace-1055184/,如需轉載,請註明出處,否則將追究法律責任。

相關文章