Thread: changes sequences to unique

changes sequences to unique

From
Dave Stokes
Date:
I have a sequence that I 'thought' was providing unique numbers but is
not.  Is there someway to turn on unique-ness?  Should I reload after
adding unique to the sequence?  Any other thoughts on digging my way out
of the problem?

Thanks in advance!
--

Dave Stokes
dave@greatgeek.com
817 329 9317


Re: changes sequences to unique

From
Stephan Szabo
Date:
On Wed, 6 Jun 2001, Dave Stokes wrote:

> I have a sequence that I 'thought' was providing unique numbers but is
> not.  Is there someway to turn on unique-ness?  Should I reload after
> adding unique to the sequence?  Any other thoughts on digging my way out
> of the problem?

They should provide unique numbers.  You could get non-unique values in
a column with a sequence default if you manually insert values (the
sequence wouldn't know about these).  Can you give a sequence of events
from a blank start to replicate what you're seeing?



Re: changes sequences to unique

From
Tom Lane
Date:
Dave Stokes <dave@greatgeek.com> writes:
> I have a sequence that I 'thought' was providing unique numbers but is
> not.  Is there someway to turn on unique-ness?

Huh?  nextval() should always produce unique values (unless the sequence
wraps around, of course).

            regards, tom lane

Re: changes sequences to unique

From
"Thalis A. Kalfigopoulos"
Date:
How did you conclude that it doesn't provide unique numbers? A sequence gives unique values by definition (unless you
allowit to cycle and you actually wrapped around the 2.1billion boundary) 

cheers,
thalis


On Wed, 6 Jun 2001, Dave Stokes wrote:

> I have a sequence that I 'thought' was providing unique numbers but is
> not.  Is there someway to turn on unique-ness?  Should I reload after
> adding unique to the sequence?  Any other thoughts on digging my way out
> of the problem?
>
> Thanks in advance!
> --
>
> Dave Stokes
> dave@greatgeek.com
> 817 329 9317
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>


Re: changes sequences to unique

From
Stefan Huber
Date:
>Huh?  nextval() should always produce unique values (unless the sequence
>wraps around, of course).

What about explicitly overruling a sequence by INSERTing a specific value,
when it is not a primary key or defined as serial, but a manual sequence?

Stefan

--
I don't find it hard to meet expenses. They're everywhere!


Re: changes sequences to unique

From
Rene Pijlman
Date:
dave@greatgeek.com (Dave Stokes) schreef:
>I have a sequence that I 'thought' was providing unique numbers but is
>not. Is there someway to turn on unique-ness?

Sequences are documented on
http://www.postgresql.org/users-lounge/docs/7.1/reference/sql-createsequence.html

The numbers may not be unique if:
- there are already values in the column that conflict with numbers
(to be) generated by the sequence
- it was created with "cycle" and it cycles
- values are inserted into the column that have not been generated by
the sequence
- there is more than one sequence inserting values into the column
- there is a trigger that interferes
- ...

>Should I reload after adding unique to the sequence?

I'm not sure what you mean by that.

--
Vriendelijke groet,
René Pijlman <rpijlman@spamcop.net>

Wat wil jij leren?
http://www.leren.nl/

Re: changes sequences to unique

From
Rene Pijlman
Date:
schweinsaug@crosswinds.net (Stefan Huber) schreef:
>>Huh?  nextval() should always produce unique values (unless the sequence
>>wraps around, of course).
>
>What about explicitly overruling a sequence by INSERTing a specific value,
>when it is not a primary key or defined as serial, but a manual sequence?

Then the sequence will still produce unique values. Its just the
database column that contains a duplicate :-)

--
Vriendelijke groet,
René Pijlman <rpijlman@spamcop.net>

Wat wil jij leren?
http://www.leren.nl/