日期:2014-05-16 浏览次数:20336 次
1.存储过程如下:
create or replace procedure pr_CreateIdentityColumn
(tablename varchar2,columnname varchar2)
as
strsql varchar2(1000);
begin
strsql := ’create sequence seq_’||tablename||’ minvalue 1 maxvalue 999999999999999999 start with 1 increment by 1 nocache’;
execute immediate strsql;
strsql := ’create or replace trigger trg_’||tablename||’ before insert on ’||tablename||’ for each row begin select seq_’||tablename||’.nextval into :new.’||columnname||’ from dual; end;’;
execute immediate strsql;
end;