What is the cleanest way to limit an SQL table so that it has no more than one row?
This related question discusses why such a table may exist, but not how this restriction should be implemented.
So far, I have only discovered hacks with a unique key column that is limited to a specific value, for example. ALWAYS_0 TINYINT NOT NULL PRIMARY KEY DEFAULT (0) CONSTRAINT CHECK_ALWAYS_0 CHECK (ALWAYS_0 = 0). I guess there is probably a cleaner way to do this.
An ideal solution would be portable SQL, but a solution specific to MS SQL Server or postgres would also be useful.
finnw source
share