导入表数据时要修改表对应的序列值方法:
declare
startValue number;
num number;
seq_name varchar2(100) := 'SQN_POST_INFO'; --序列名称
begin
--查出序列开始值
select max(nbi.POST_ID)+1 into startValue from POST_INFO nbi;
--查序列是否存在,存在删除
select count(1) into num from dba_objects db where db.Object_Type='SEQUENCE' AND db.object_name=seq_name;
if num > 0 then
EXECUTE IMMEDIATE 'drop sequence ' || seq_name;
end if;
--创建序列
EXECUTE IMMEDIATE 'create sequence ' || seq_name || ' minvalue 1 maxvalue 999999999999999999999999999 start with '|| startValue || ' increment by 1 cache 20'; end;