Re: COPY data into a table with a SERIAL column?

From: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: COPY data into a table with a SERIAL column?
Date: 2014-10-16 17:52:38
Message-ID: CAKFQuwbHfqmUftOoq9-1=NPRsvw=dx3DRH8S=pduRCtwuy3ktQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Oct 16, 2014 at 11:44 AM, lup [via PostgreSQL] <
ml-node+s1045698n5823292h76(at)n5(dot)nabble(dot)com> wrote:

>
>
> I appreciate the vastness of bigserial but I think it starts at 1. Are
> negative numbers even allowed?

​http://www.postgresql.org/docs/9.3/static/sql-createsequence.html

A DEFAULT sequence starts at one but it is able to generate any biginteger
value.​ Regardless, the value generated by the sequence and the allowed
values for the target column are distinct - which is why a sequence
attached to a normal integer will start throwing "value out of bounds"
errors before it runs out of values.

Therefore, by default if one is able to live with disallowing half of the
bigint range for auto-generation using the negative half of the range for
manual assignment is a quick-and-simple solution to the problem.

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/COPY-data-into-a-table-with-a-SERIAL-column-tp5823278p5823296.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Sargent 2014-10-16 17:58:23 Re: COPY data into a table with a SERIAL column?
Previous Message Andreas Kretschmer 2014-10-16 17:50:13 Re: How to Install Extensions