Tag Info

New answers tagged

0

One way is to add discriminator column, something like create table c (id_c int not null, val char(1)) create index idx_c1 on c(id_c,val); alter table c add constraint chk_val check(val in ('a','b')); alter table c add constraint c_pk primary key (id_c) using index idx_c1; alter table c add constraint c_uq unique (id_c,val) using index idx_c1; create ...


5

If you really need to run multiple threads at the same time you can enable the ignore_dup_key option on the primary key. This will just give a warning instead of an error when an insert would result in a duplicate key violation. But instead of failing it will discard the row(s) that if inserted would cause the uniqueness violation. CREATE TABLE ...


0

The name of the table DeleteMe suggests that you are accumulating IDs into this table and then periodically delete rows with these IDs from some other permanent table. Is it true? If it is true, then you can allow DeleteMe to have duplicate IDs. Just have a non-unique index on id instead of unique (and since id is uniqueidentifier it makes sense to make ...



Top 50 recent answers are included