Re: limit table to one row

Lists: pgsql-general
From: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: limit table to one row
Date: 2009-06-04 20:13:25
Message-ID: Pine.LNX.4.58L.0906041511290.17533@cedar.geronimoalloys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

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.

--
Brandon


From: Richard Broersma <richard(dot)broersma(at)gmail(dot)com>
To: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-04 20:17:34
Message-ID: 396486430906041317l63722800mc5178698bbe89827@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Thu, Jun 4, 2009 at 1:13 PM, Brandon Metcalf
<brandon(at)geronimoalloys(dot)com> wrote:
> Is there a way when creating a table to limit it to one row?  That is,
> without using a stored procedure?

Sure just add a check constraint along the lines of:

CONSTRAINT Only_one_row
CHECK( tableuniqueid = 1 ); --assuming you row has a unique id of 1

--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug


From: Richard Broersma <richard(dot)broersma(at)gmail(dot)com>
To: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-04 20:17:49
Message-ID: 396486430906041317l1ac3092ep70d4960df8e0032d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Thu, Jun 4, 2009 at 1:13 PM, Brandon Metcalf
<brandon(at)geronimoalloys(dot)com> wrote:
> Is there a way when creating a table to limit it to one row?  That is,
> without using a stored procedure?

Sure just add a check constraint along the lines of:

CONSTRAINT Only_one_row
CHECK( tableuniqueid = 1 ); --assuming you row has a unique id of 1

--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug


From: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>
To: Richard Broersma <richard(dot)broersma(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-04 20:23:28
Message-ID: Pine.LNX.4.58L.0906041521360.17533@cedar.geronimoalloys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

r == richard(dot)broersma(at)gmail(dot)com writes:

r> On Thu, Jun 4, 2009 at 1:13 PM, Brandon Metcalf
r> <brandon(at)geronimoalloys(dot)com> wrote:
r> > Is there a way when creating a table to limit it to one row? That is,
r> > without using a stored procedure?

r> Sure just add a check constraint along the lines of:

r> CONSTRAINT Only_one_row
r> CHECK( tableuniqueid = 1 ); --assuming you row has a unique id of 1

Got it. Currently, it doesn't have a column for an ID, but I can add
one if this is the only way.

--
Brandon


From: Richard Broersma <richard(dot)broersma(at)gmail(dot)com>
To: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-04 20:30:29
Message-ID: 396486430906041330n18921c62s9f094c58c00ea7be@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Thu, Jun 4, 2009 at 1:23 PM, Brandon Metcalf
<brandon(at)geronimoalloys(dot)com> wrote:

> Got it.  Currently, it doesn't have a column for an ID, but I can add
> one if this is the only way.

Actually any column with a unique index on it will work. It doesn't
have to be primary key or even a serial id.

ANSI-SQL 92 allows for the following syntax:

CONSTRAINT Only_one_row
CHECK( 1 >= (SELECT COUNT(*) FROM _this_table;));

However, I have yet to find a RDBMS (PostgreSQL included) that
supports select statements in a table's check constraint.

--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug


From: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>
To: Richard Broersma <richard(dot)broersma(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-04 20:35:27
Message-ID: Pine.LNX.4.58L.0906041534170.17533@cedar.geronimoalloys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

r == richard(dot)broersma(at)gmail(dot)com writes:

r> On Thu, Jun 4, 2009 at 1:23 PM, Brandon Metcalf
r> <brandon(at)geronimoalloys(dot)com> wrote:

r> > Got it. Currently, it doesn't have a column for an ID, but I can add
r> > one if this is the only way.

r> Actually any column with a unique index on it will work. It doesn't
r> have to be primary key or even a serial id.

r> ANSI-SQL 92 allows for the following syntax:

r> CONSTRAINT Only_one_row
r> CHECK( 1 >= (SELECT COUNT(*) FROM _this_table;));

r> However, I have yet to find a RDBMS (PostgreSQL included) that
r> supports select statements in a table's check constraint.

I had thought about a subquery in the constraint, but as you say, that
didn't work.

Thanks for the help.

--
Brandon


From: Niklas Johansson <pgmailings(at)codecraft(dot)se>
To: Richard Broersma <richard(dot)broersma(at)gmail(dot)com>
Cc: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-04 23:03:56
Message-ID: F31071A3-6CDD-46B5-83AC-93C777BD16E0@codecraft.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


On 4 jun 2009, at 22.17, Richard Broersma wrote:

> On Thu, Jun 4, 2009 at 1:13 PM, Brandon Metcalf
> <brandon(at)geronimoalloys(dot)com> wrote:
>> Is there a way when creating a table to limit it to one row? That
>> is,
>> without using a stored procedure?
>
>
> Sure just add a check constraint along the lines of:
>
> CONSTRAINT Only_one_row
> CHECK( tableuniqueid = 1 ); --assuming you row has a unique id
> of 1

Another way, which I've used a couple of times, is to use the rule
system:

CREATE TABLE single_row (value text);
INSERT INTO single_row VALUES ('value');
CREATE RULE no_insert AS ON INSERT TO single_row DO INSTEAD NOTHING;
CREATE RULE no_delete AS ON DELETE TO single_row DO INSTEAD NOTHING;

This way, the table must have exactly one row. I believe the
constraint check would still allow the row to be deleted, which you
may or may not want.

If you want an error to be raised when inserting or deleting, you'd
have to call a function raising the error in the rule. A minor
drawback is that the table still isn't safe from TRUNCATE though.

Sincerely,

Niklas Johansson


From: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>
To: Niklas Johansson <pgmailings(at)codecraft(dot)se>
Cc: Richard Broersma <richard(dot)broersma(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-05 16:13:12
Message-ID: Pine.LNX.4.58L.0906051111060.17533@cedar.geronimoalloys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

p == pgmailings(at)codecraft(dot)se writes:

p> On 4 jun 2009, at 22.17, Richard Broersma wrote:

p> > On Thu, Jun 4, 2009 at 1:13 PM, Brandon Metcalf
p> > <brandon(at)geronimoalloys(dot)com> wrote:
p> >> Is there a way when creating a table to limit it to one row? That
p> >> is,
p> >> without using a stored procedure?
p> >
p> >
p> > Sure just add a check constraint along the lines of:
p> >
p> > CONSTRAINT Only_one_row
p> > CHECK( tableuniqueid = 1 ); --assuming you row has a unique id
p> > of 1

p> Another way, which I've used a couple of times, is to use the rule
p> system:

p> CREATE TABLE single_row (value text);
p> INSERT INTO single_row VALUES ('value');
p> CREATE RULE no_insert AS ON INSERT TO single_row DO INSTEAD NOTHING;
p> CREATE RULE no_delete AS ON DELETE TO single_row DO INSTEAD NOTHING;

p> This way, the table must have exactly one row. I believe the
p> constraint check would still allow the row to be deleted, which you
p> may or may not want.

p> If you want an error to be raised when inserting or deleting, you'd
p> have to call a function raising the error in the rule. A minor
p> drawback is that the table still isn't safe from TRUNCATE though.

Thanks for the info. The data in the table in question is easy to
recreate if it gets deleted. The main thing is to prevent more than
one row, so using CHECK( tableuniqueid = 1 ) works fine.

--
Brandon


From: Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>
To: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-06 16:30:49
Message-ID: 2f4958ff0906060930q13ef947av14f6f4b1570d4d39@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

just change whatever you are storing to be in vertical structure,
instead of horizontal. so instead of create table foo(a int, b int, c
int, etc), try:

create table foo(name varchar, val int);

common mistake I've seen committed by people..


From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-06 18:00:27
Message-ID: b42b73150906061100h61cc0f64jeeced20fc1c98765@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Thu, Jun 4, 2009 at 4:13 PM, Brandon
Metcalf<brandon(at)geronimoalloys(dot)com> 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.
>
> --

you can also do it with a trigger.

create or replace function one_row () returns trigger as
$$
declare
_rows bigint;
begin
execute 'select count(*) from ' || tg_relname into _rows;

if _rows > 1 then
raise exception 'one row only please';
end if;

return new;
end;
$$ language plpgsql;

create table one_row(id int);
create trigger on_one_row after insert on one_row execute procedure one_row();

as written, you only need one trigger function, and can attach it to
multiple tables. this has a couple of (small) advantages over the
unique constraint method...its more general and can satisfy a broader
range of conditions, is checked at the end of statement, not at each
row, and does not requires arbitrary annotation in the table.

merlin


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-06 18:07:42
Message-ID: 12466.1244311662@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Merlin Moncure <mmoncure(at)gmail(dot)com> writes:
> On Thu, Jun 4, 2009 at 4:13 PM, Brandon
> Metcalf<brandon(at)geronimoalloys(dot)com> wrote:
>> Is there a way when creating a table to limit it to one row? That is,
>> without using a stored procedure?

> you can also do it with a trigger.

If you're willing to use a trigger, just insert the one allowed row
and then install a trigger that throws error for any insert or delete
attempt ...

regards, tom lane


From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-06 18:12:04
Message-ID: b42b73150906061112j3a74caa6od9a71ac7ebe925fb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Sat, Jun 6, 2009 at 2:07 PM, Tom Lane<tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Merlin Moncure <mmoncure(at)gmail(dot)com> writes:
>> On Thu, Jun 4, 2009 at 4:13 PM, Brandon
>> Metcalf<brandon(at)geronimoalloys(dot)com> wrote:
>>> Is there a way when creating a table to limit it to one row?  That is,
>>> without using a stored procedure?
>
>> you can also do it with a trigger.
>
> If you're willing to use a trigger, just insert the one allowed row
> and then install a trigger that throws error for any insert or delete
> attempt ...

what if you need to delete then insert? :-)

merlin


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-06 18:29:36
Message-ID: 12808.1244312976@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Merlin Moncure <mmoncure(at)gmail(dot)com> writes:
> On Sat, Jun 6, 2009 at 2:07 PM, Tom Lane<tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> If you're willing to use a trigger, just insert the one allowed row
>> and then install a trigger that throws error for any insert or delete
>> attempt ...

> what if you need to delete then insert? :-)

Hmm ... I supposed the requirement was "always exactly one row".
If it's "always zero or one row", then you're right.

regards, tom lane


From: "Leif B(dot) Kristensen" <leif(at)solumslekt(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-06 21:27:56
Message-ID: 200906062327.56905.leif@solumslekt.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Saturday 6. June 2009, Grzegorz Jaśkiewicz wrote:
>just change whatever you are storing to be in vertical structure,
>instead of horizontal. so instead of create table foo(a int, b int, c
>int, etc), try:
>
>create table foo(name varchar, val int);
>
>common mistake I've seen committed by people..

That sounds a lot like EAV.
--
Leif Biberg Kristensen | Registered Linux User #338009
Me And My Database: http://solumslekt.org/blog/


From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-07 05:38:58
Message-ID: 4A2B5272.3000506@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Brandon Metcalf 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));

--
Craig Ringer


From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
Cc: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-08 13:19:23
Message-ID: b42b73150906080619s5eb4650cud0e0daf75e601fee@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Sun, Jun 7, 2009 at 1:38 AM, Craig Ringer<craig(at)postnewspapers(dot)com(dot)au> wrote:
> Brandon Metcalf 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


From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-09 12:39:59
Message-ID: h0ll6v$90o$8@reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 2009-06-04, Brandon Metcalf <brandon(at)geronimoalloys(dot)com> 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 a unique index, and a constraint to a single value on one of
the columns :)


From: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>
To: Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-09 14:56:04
Message-ID: Pine.LNX.4.58L.0906090955330.11099@cedar.geronimoalloys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

g == gryzman(at)gmail(dot)com writes:

g> just change whatever you are storing to be in vertical structure,
g> instead of horizontal. so instead of create table foo(a int, b int, c
g> int, etc), try:

g> create table foo(name varchar, val int);

g> common mistake I've seen committed by people..

I'm not sure I follow how this solves the problem.

--
Brandon


From: Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>
To: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-09 15:08:58
Message-ID: 2f4958ff0906090808m41c3737cn304fabdcb722363e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

2009/6/9 Brandon Metcalf <brandon(at)geronimoalloys(dot)com>:

> I'm not sure I follow how this solves the problem.

Well, surely if you just need one row, you need single value per key.
And that's the, imo , better solution to that problem, than limiting
number of rows.

--
GJ


From: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>
To: Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-09 15:24:01
Message-ID: Pine.LNX.4.58L.0906091011340.11099@cedar.geronimoalloys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

g == gryzman(at)gmail(dot)com writes:

g> 2009/6/9 Brandon Metcalf <brandon(at)geronimoalloys(dot)com>:

g> > I'm not sure I follow how this solves the problem.

g> Well, surely if you just need one row, you need single value per key.
g> And that's the, imo , better solution to that problem, than limiting
g> number of rows.

Hm. Maybe I'm looking at the problem incorrectly. I have a situation
where I need a table like

CREATE TABLE foo (
start DATE,
length VARCHAR(10),
);

I need to be able to get one value for each column at any given time.
Specifically, I need to get a value for start and add the value for
length to get a time period. Since your approach would allow more
than one row, how does it help me?

--
Brandon


From: Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>
To: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-09 15:37:48
Message-ID: 2f4958ff0906090837w7d945027y109573f9615ad369@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

2009/6/9 Brandon Metcalf <brandon(at)geronimoalloys(dot)com>:

>
>  CREATE TABLE foo (
>    start  DATE,
>    length VARCHAR(10),
>  );
>
> I need to be able to get one value for each column at any given time.
> Specifically, I need to get a value for start and add the value for
> length to get a time period.  Since your approach would allow more
> than one row, how does it help me?

If you want to store period of time, why store it as varchar ?

just store two rows
create table foo(
n varchar,
val date
);

and store two rows:
"start", now(),
"end", now()+'something '::interval

Wouldn't that do, or is there something I misunderstand ?

The approach with vertical structure, is used when people want to
store some particular state, say - kind of like structure in C, but in
SQL, and they create table for it with all the columns, etc, and have
to limit it to one row.

On the other hand, you could also use unique index on (1) approach
(say if you need more variety of types).

--
GJ


From: Brandon Metcalf <brandon(at)geronimoalloys(dot)com>
To: Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-09 15:45:52
Message-ID: Pine.LNX.4.58L.0906091042420.11099@cedar.geronimoalloys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

g == gryzman(at)gmail(dot)com writes:

g> If you want to store period of time, why store it as varchar ?

g> just store two rows
g> create table foo(
g> n varchar,
g> val date
g> );

g> and store two rows:
g> "start", now(),
g> "end", now()+'something '::interval

g> Wouldn't that do, or is there something I misunderstand ?

Sure, that would work, but I'm having to retrofit this table to an
existing system. Much of the system I'm redesigning, but this piece
isn't too terribly important right now.

g> The approach with vertical structure, is used when people want to
g> store some particular state, say - kind of like structure in C, but in
g> SQL, and they create table for it with all the columns, etc, and have
g> to limit it to one row.

g> On the other hand, you could also use unique index on (1) approach
g> (say if you need more variety of types).

Got it.

--
Brandon


From: "Octavio Alvarez" <alvarezp(at)alvarezp(dot)ods(dot)org>
To: "Brandon Metcalf" <brandon(at)geronimoalloys(dot)com>, Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-09 16:25:14
Message-ID: op.uu9mhwk84oyyg1@alvarezp-ws
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Tue, 09 Jun 2009 08:24:01 -0700, Brandon Metcalf
<brandon(at)geronimoalloys(dot)com> wrote:
>
> CREATE TABLE foo (
> start DATE,
> length VARCHAR(10),
> );
>
> I need to be able to get one value for each column at any given time.

CREATE UNIQUE INDEX u ON foo ((start IS NOT NULL));

You would just make sure you SELECT FROM foo WHERE start IS NOT NULL;

However, it doesn't prevent you from having 0 rows on the table.


From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: limit table to one row
Date: 2009-06-10 12:19:55
Message-ID: h0o8db$7jc$1@reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 2009-06-09, Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com> wrote:
> 2009/6/9 Brandon Metcalf <brandon(at)geronimoalloys(dot)com>:
>
>
>> I'm not sure I follow how this solves the problem.
>
> Well, surely if you just need one row, you need single value per key.
> And that's the, imo , better solution to that problem, than limiting
> number of rows.

not really, if different keys have different types of values
associated.

one application I work with has a config table with atleast text, integer,
interval, and boolean values.

>
>
> --
> GJ
>