Re: [GENERAL] [pgsql-general] Daily digest v1.9081 (14 messages)

2009-06-08 Thread Oliver Kohll - Mailing Lists

On 8 Jun 2009, at 17:23, Merlin Moncure  wrote:

Is there a way when creating a table to limit it to one row?  That  
is,

without using a stored procedure?

I searched the documentation, but didn't find anything.




CREATE TABLE x (...);

CREATE UNIQUE INDEX x_only_one_row ON ((1));


very clever :D

merlin


To clever for me, I don't understand what's going on and can't  
replicate it in my 8.3. Any expansion?


Rgs
Oliver

oli...@gtwm.co.uk / 0845 456 1810 / 07814 828608
www.gtwm.co.uk - company
www.gtportalbase.com - product



Re: [GENERAL] [pgsql-general] Daily digest v1.9081 (14 messages)

2009-06-11 Thread David Fetter
On Mon, Jun 08, 2009 at 08:08:02PM +0100, Oliver Kohll - Mailing Lists wrote:
> On 8 Jun 2009, at 17:23, Merlin Moncure  wrote:
>
 Is there a way when creating a table to limit it to one row?  That  
 is,
 without using a stored procedure?

 I searched the documentation, but didn't find anything.

>>>
>>>
>>> CREATE TABLE x (...);
>>>
>>> CREATE UNIQUE INDEX x_only_one_row ON ((1));
>>
>> very clever :D
>>
>> merlin
>
> To clever for me, I don't understand what's going on and can't
> replicate it in my 8.3.  Any expansion?

This should actually read:

CREATE UNIQUE INDEX x_only_one_row ON x((1));

This creates a unique expressional index on the table.  This
expression evaluates as true only in cases where the table has at most
one row, independently of what the possible row contains.

Cheers,
David.
-- 
David Fetter  http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter  XMPP: david.fet...@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general