On 12/29/2016 02:23 PM, Fabien COELHO wrote:
>
>> There is a singleton table :)
>>
>> create table foo(x integer unique not null default 1 check(x = 1), y
>> integer);
>> insert into foo(y) values(100);
>> analyze foo;
>
> I know this one. It can be empty, which a singleton cannot be. For a
> singleton table, you should have one and only one row, you cannot
> insert or delete, so this is only part of the real thing.
Surely we can do a bit better than that, if that's what you really want.
Create the table with an initial row and add a trigger preventing
anything except update.
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services