1
I noticed that one of the tables had a balance from 9 to 1001. At first I imagined that some colleague would have done a test in the bank and deleted the record in sequence causing the number to have this jump.
Now it has happened to another table without anyone having made an Index with a later deletion. Has anyone had this problem? This is the table:
CREATE TABLE [dbo].[PcpsRota](
[RotaId] [int] IDENTITY(1,1) NOT NULL,
[EmpId] [int] NOT NULL,
[RotaDes] [varchar](80) NOT NULL,
[UsuId] [int] NOT NULL,
[UsuDta] [datetime] NOT NULL,
[UltUsuId] [int] NOT NULL,
[UltDta] [datetime] NOT NULL,
[RotaSit] [smallint] NOT NULL,
PRIMARY KEY CLUSTERED
(
[RotaId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[PcpsRota] ADD DEFAULT (getdate()) FOR [UltDta]
GO
ALTER TABLE [dbo].[PcpsRota] ADD CONSTRAINT [DF_RotaSit] DEFAULT ((2)) FOR [RotaSit]
GO
ALTER TABLE [dbo].[PcpsRota] WITH CHECK ADD CONSTRAINT [CHK_PcpsRota_UltimoUsuario_DeveSerInformado] CHECK (([UltUsuId]>(0)))
GO
ALTER TABLE [dbo].[PcpsRota] CHECK CONSTRAINT [CHK_PcpsRota_UltimoUsuario_DeveSerInformado]
GO
Dude, I read a case that looks a lot like yours. Except it’s related to postgres, but maybe reading about this case can explain why: article. In this case they resolved to stop using sequences generated by the database.
– Danizavtz