pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Single row tables
4+ messages / 3 participants
[nested] [flat]

* Single row tables
@ 2005-01-11 14:45  KÖPFERL Robert <robert.koepferl@sonorys.at>
  0 siblings, 1 reply; 4+ messages in thread

From: KÖPFERL Robert @ 2005-01-11 14:45 UTC (permalink / raw)
  To: ; +Cc: pgsql-sql

Hi,

with what constraint or how can I ensure that one of my tables has exact one
record or 0..1 records?



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Single row tables
@ 2005-01-11 14:50  Dmitri Bichko <dbichko@genpathpharma.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Dmitri Bichko @ 2005-01-11 14:50 UTC (permalink / raw)
  To: KÖPFERL Robert <robert.koepferl@sonorys.at>; +Cc: pgsql-sql

I suppose you could put a check constraint that forces a single value on a column with a unique index?  Or an insert trigger that always inserts the same value into a unique field.

Out of curiosity, why do you need to do this?

Dmitri

-----Original Message-----
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of KÖPFERL Robert
Sent: Tuesday, January 11, 2005 9:46 AM
Cc: pgsql-sql@postgresql.org
Subject: [SQL] Single row tables
Importance: High


Hi,

with what constraint or how can I ensure that one of my tables has exact one record or 0..1 records?

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Single row tables
@ 2005-01-11 15:17  KÖPFERL Robert <robert.koepferl@sonorys.at>
  0 siblings, 0 replies; 4+ messages in thread

From: KÖPFERL Robert @ 2005-01-11 15:17 UTC (permalink / raw)
  To: ; +Cc: pgsql-sql

Also I thought of an UNIQUE constraint on a column with =const constraint.
But .... 

It's for global configuration data that exists only once.
Making a key value thing was to weak typed for my taste.

> -----Original Message-----
> From: Dmitri Bichko [mailto:dbichko@genpathpharma.com]
> Sent: Dienstag, 11. Jänner 2005 15:50
> To: KÖPFERL Robert
> Cc: pgsql-sql@postgresql.org
> Subject: RE: [SQL] Single row tables
> 
> 
> I suppose you could put a check constraint that forces a 
> single value on a column with a unique index?  Or an insert 
> trigger that always inserts the same value into a unique field.
> 
> Out of curiosity, why do you need to do this?
> 
> Dmitri
> 
> -----Original Message-----
> From: pgsql-sql-owner@postgresql.org 
> [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of KÖPFERL Robert
> Sent: Tuesday, January 11, 2005 9:46 AM
> Cc: pgsql-sql@postgresql.org
> Subject: [SQL] Single row tables
> Importance: High
> 
> 
> Hi,
> 
> with what constraint or how can I ensure that one of my 
> tables has exact one record or 0..1 records?
> 
> ---------------------------(end of 
> broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
> 



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Single row tables
@ 2005-01-12 06:39  sad <sad@bankir.ru>
  parent: KÖPFERL Robert <robert.koepferl@sonorys.at>
  0 siblings, 0 replies; 4+ messages in thread

From: sad @ 2005-01-12 06:39 UTC (permalink / raw)
  To: KÖPFERL Robert <robert.koepferl@sonorys.at>; +Cc: pgsql-sql

On Tuesday 11 January 2005 17:45, KÖPFERL Robert wrote:
> Hi,
>
> with what constraint or how can I ensure that one of my tables has exact
> one record or 0..1 records?

A trigger procedure BEFORE INSERT would help you.

And a column type with only one possible field value would help you if you 
define UNIQUE INDEX on a field of this (user-defined) type.



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2005-01-12 06:39 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-01-11 14:45 Single row tables KÖPFERL Robert <robert.koepferl@sonorys.at>
2005-01-12 06:39 ` sad <sad@bankir.ru>
2005-01-11 14:50 Re: Single row tables Dmitri Bichko <dbichko@genpathpharma.com>
2005-01-11 15:17 Re: Single row tables KÖPFERL Robert <robert.koepferl@sonorys.at>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox