pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to make sequence skip existing key in table?
4+ messages / 3 participants
[nested] [flat]

* How to make sequence skip existing key in table?
@ 2003-02-18 10:01 Raymond Pau <rpau@yahoo.com>
  2003-02-18 13:43 ` Re: How to make sequence skip existing key in table? Bruno Wolff III <bruno@wolff.to>
  2003-02-18 17:07 ` Re: How to make sequence skip existing key in table? Josh Berkus <josh@agliodbs.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Raymond Pau @ 2003-02-18 10:01 UTC (permalink / raw)
  To: pgsql-sql

Hi List,

I am using sequence to generate to a list of unique
key id that will be used as the primary key for some
tables.

My question is when the sequence wraps over to the
minimum value(1), how can I ensure that the next id is
not in the tables?

Regards,

Raymond Pau

__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com



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

* Re: How to make sequence skip existing key in table?
  2003-02-18 10:01 How to make sequence skip existing key in table? Raymond Pau <rpau@yahoo.com>
@ 2003-02-18 13:43 ` Bruno Wolff III <bruno@wolff.to>
  1 sibling, 0 replies; 4+ messages in thread

From: Bruno Wolff III @ 2003-02-18 13:43 UTC (permalink / raw)
  To: Raymond Pau <rpau@yahoo.com>; +Cc: pgsql-sql

On Tue, Feb 18, 2003 at 02:01:34 -0800,
  Raymond Pau <rpau@yahoo.com> wrote:
> Hi List,

Please don't start new threads by replying to other messages on the list.
This screws up threading of messages, which is useful for following specific
discussions.

> I am using sequence to generate to a list of unique
> key id that will be used as the primary key for some
> tables.
> 
> My question is when the sequence wraps over to the
> minimum value(1), how can I ensure that the next id is
> not in the tables?

My suggestion is to use the bigserial type. This uses bigint as the underlying
type and you are not likely to roll over a 64 bit integer unless you are
wasting a lot of serial values for each one you actually use.



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

* Re: How to make sequence skip existing key in table?
  2003-02-18 10:01 How to make sequence skip existing key in table? Raymond Pau <rpau@yahoo.com>
@ 2003-02-18 17:07 ` Josh Berkus <josh@agliodbs.com>
  2003-02-21 06:29   ` Re: How to make sequence skip existing key in table? Raymond Pau <rpau@yahoo.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Josh Berkus @ 2003-02-18 17:07 UTC (permalink / raw)
  To: Raymond Pau <rpau@yahoo.com>; pgsql-sql

Raymond,

> I am using sequence to generate to a list of unique
> key id that will be used as the primary key for some
> tables.
>
> My question is when the sequence wraps over to the
> minimum value(1), how can I ensure that the next id is
> not in the tables?

Do you really expect more than 2.4 billion rows?

-- 
Josh Berkus
Aglio Database Solutions
San Francisco



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

* Re: How to make sequence skip existing key in table?
  2003-02-18 10:01 How to make sequence skip existing key in table? Raymond Pau <rpau@yahoo.com>
  2003-02-18 17:07 ` Re: How to make sequence skip existing key in table? Josh Berkus <josh@agliodbs.com>
@ 2003-02-21 06:29   ` Raymond Pau <rpau@yahoo.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Raymond Pau @ 2003-02-21 06:29 UTC (permalink / raw)
  To: pgsql-sql


--- Josh Berkus <josh@agliodbs.com> wrote:
> Raymond,
> 
> > I am using sequence to generate to a list of
> unique
> > key id that will be used as the primary key for
> some
> > tables.
> >
> > My question is when the sequence wraps over to the
> > minimum value(1), how can I ensure that the next
> id is
> > not in the tables?
> 
> Do you really expect more than 2.4 billion rows?

No, not really.
I guess my worries are groundless after all.

Thanks.
> 
> -- 
> Josh Berkus
> Aglio Database Solutions
> San Francisco


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/



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


end of thread, other threads:[~2003-02-21 06:29 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-02-18 10:01 How to make sequence skip existing key in table? Raymond Pau <rpau@yahoo.com>
2003-02-18 13:43 ` Bruno Wolff III <bruno@wolff.to>
2003-02-18 17:07 ` Josh Berkus <josh@agliodbs.com>
2003-02-21 06:29   ` Raymond Pau <rpau@yahoo.com>

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