可以写个dbms_job定时删除序列并重建。存储过程如下:
目前创新互联已为上千多家的企业提供了网站建设、域名、雅安服务器托管、网站托管、企业网站设计、环江网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
create or replace procedure prc_mq_resetsequence(seqname in varchar2) authid current_user is
num number;
begin
select count(*)
into num
from user_sequences
where sequence_name = upper(seqname);
if num 0 then
execute immediate 'drop sequence ' || seqname;
end if;
execute immediate 'create sequence ' || seqname ||
' minvalue 1 maxvalue 9999999999999 start with 1 increment by 1 cache 20';
end;
update A
set id = id +100
where id = (一共有多少条记录)
这样好像就可以了
oracle存储过程生成单号
oracle存储过程生成单号,Oracle生成单据编号存储过程的实例代码

旅程1229
转载
关注
0点赞·137人阅读
Oracle生成单据编号存储过程,在做订单类似的系统都可能会存在订单编号不重复,或是流水号按日,按年,按月进行重新编号。
可以参考以下存储过程
CREATE OR REPLACE
procedure Pro_GetBillNO(TypeTable in varchar2,cur_mycursor out sys_refcursor)
as
DReceiptCode varchar2(40);
DReceiptName varchar2(50);
DPrefix1 varchar2(50);
DISO varchar2(50);
DIsAutoCreate varchar2(20);
DPrefix2 varchar2(20);
DPrefix3 varchar2(20);
DDateValue date;
DNO number;
DLength number;
DResetType number;
DSeparator varchar2(20);
DReturnValue varchar2(50);
strSql varchar2(1000);
begin
DReturnValue:='';
select "ReceiptCode","ReceiptName","Prefix1","ISO","IsAutoCreate","Prefix2","Prefix3","DateValue","NO","Length","ResetType","Separator" into
DReceiptCode,DReceiptName,DPrefix1,DISO,DIsAutoCreate,DPrefix2,DPrefix3,DDateValue,DNO,DLength,DResetType,DSeparator from
"SysReceiptConfig" where "ReceiptCode"=TypeTable;
if to_number(DResetType)0
then
if DIsAutoCreate=1 THEN
if DResetType=1 then --
可以使用update select 语法进行更新
喜欢研究的可以自行学习下,以便积累
不想浪费时间可以看下面:
UPDATE A SET ID = (SELECT ROWNUM FROM A ORDER BY 时间 DESC)
参考语法:
UPDATE A SET (A1, A2, A3) = (SELECT B1, B2, B3 FROM B WHERE A.ID = B.ID)
WHERE ID IN (SELECT B.ID FROM B WHERE A.ID = B.ID)