假设AUTOID是数据库中的序列,且每个表中的autoid字段用来存储序列值。下面的脚本会将数据库中含有字段AUTOID的表筛选出来并为其创建触发器。






lower(tablename) || 'for each row ' || 'begin select autoid.nextval into :new.autoid from dual; end;';
exception
when others then
null;
end;
end loop;
end;






将此脚本在PL/SQL DEVELOPER的command window中执行。。。。。。OK!屡试不爽!!