Re: [GENERAL] Better alternative for Primary Key then serial??

2007-12-15 Thread Alban Hertroys
On Dec 13, 2007, at 14:12, John D. Burger wrote: Alban Hertroys wrote: The problem the OP is pointing out seems difficult to solve. A sequence doesn't know about existing records with a possibly higher number than the sequence is at. This may be worked around by keeping a list of numbers

Re: [GENERAL] Better alternative for Primary Key then serial??

2007-12-13 Thread Andrew Sullivan
On Wed, Dec 12, 2007 at 12:28:37PM -0800, pilzner wrote: > thats what I'm familiar with" discussion, just to get a feel of why its done > that way, if I'm doing anything wrong, or if there is an accepted way to > lock it down. It'd be easy to lock down with a trigger that RAISEs ERROR in case OLD

Re: [GENERAL] Better alternative for Primary Key then serial??

2007-12-13 Thread John D. Burger
Alban Hertroys wrote: The problem the OP is pointing out seems difficult to solve. A sequence doesn't know about existing records with a possibly higher number than the sequence is at. This may be worked around by keeping a list of numbers used up beyond the current sequence value so the

Re: [GENERAL] Better alternative for Primary Key then serial??

2007-12-13 Thread Alban Hertroys
On Dec 13, 2007, at 10:19, Jorge Godoy wrote: Em Wednesday 12 December 2007 03:42:55 pilzner escreveu: Does stuff like this cause any aches and pains to developers out there, or do I just need to get in a new mindset??? Also, is there a way to be sure the primary key is *ONLY* ever given a

Re: [GENERAL] Better alternative for Primary Key then serial??

2007-12-13 Thread Jorge Godoy
Em Wednesday 12 December 2007 03:42:55 pilzner escreveu: > > Does stuff like this cause any aches and pains to developers out there, or > do I just need to get in a new mindset??? Also, is there a way to be sure > the primary key is *ONLY* ever given a value by serial, and not subject to > updates?

Re: [GENERAL] Better alternative for Primary Key then serial??

2007-12-12 Thread Alvaro Herrera
pilzner wrote: > > > > Alvaro Herrera-3 wrote: > > > > Just do not update the ID -- what use do you have for that > > anyway? If you want to prevent it, you can put a trigger to the column, > > but IMHO it would be a waste of your time and machine resources. > > > > I have absolutely no use

Re: [GENERAL] Better alternative for Primary Key then serial??

2007-12-12 Thread pilzner
Alvaro Herrera-3 wrote: > > Just do not update the ID -- what use do you have for that > anyway? If you want to prevent it, you can put a trigger to the column, > but IMHO it would be a waste of your time and machine resources. > I have absolutely no use to update the ID. I'm not sure why an

Re: [GENERAL] Better alternative for Primary Key then serial??

2007-12-12 Thread Alvaro Herrera
pilzner wrote: > Does stuff like this cause any aches and pains to developers out there, or > do I just need to get in a new mindset??? Also, is there a way to be sure > the primary key is *ONLY* ever given a value by serial, and not subject to > updates??? It doesn't. Just do not update the ID

Re: [GENERAL] Better alternative for Primary Key then serial??

2007-12-12 Thread Adrian Klaver
On Tuesday 11 December 2007 9:42 pm, pilzner wrote: > Hi - I'm new to PostGres, but have used MSSQL for about a year. I'm going > through the documentation, but after reading about serials have a lot of > worries about keeping referential integrity in place and other things. > Specifically, here ar

[GENERAL] Better alternative for Primary Key then serial??

2007-12-12 Thread pilzner
Hi - I'm new to PostGres, but have used MSSQL for about a year. I'm going through the documentation, but after reading about serials have a lot of worries about keeping referential integrity in place and other things. Specifically, here are a few scenarios: a.) CREATE TABLE TestTable ( TestID SE