There is such a crazy option:
UPDATE actives SET active = (id = 1); -- ^^^^^^^^ это ж boolean!
The condition will be met if there is a UNIQUE on the sample field, so that only one row of the table can be true from the equality. However, if there is no such key in the table at all , everything will be reset to false . You can add a condition to an id containing a SELECT from the same table to avoid such situations.
I consider it insane because the base is unlikely to guess how many records will really change as a result of the request, and we know that there are always no more than two . The base will bypass all lines.
But it is necessary to measure the performance and find out, perhaps this problem exists only in my head. But even if not, a quicker integrity integrity solution may simply not exist. I dont know.
Yevgeny Borisov correctly notes in the comments to the question that it is much more efficient to store the primary key of the active record in another place. The only place you can atomically change with much smaller locks.