Re: portable DBAPI auto-increment

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: Mark Sienkiewicz <sienkiew(at)stsci(dot)edu>
Cc: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>, psycopg(at)postgresql(dot)org
Subject: Re: portable DBAPI auto-increment
Date: 2011-04-08 18:09:29
Message-ID: 4D9F4F59.50701@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On 04/08/2011 10:43 AM, Mark Sienkiewicz wrote:
> Daniele Varrazzo wrote:

>
>
> I did an experiment:
>
> test=# create table foo ( k serial, v varchar(10) );
> NOTICE: CREATE TABLE will create implicit sequence "foo_k_seq" for
> serial column "foo.k"
> CREATE TABLE
> test=# insert into foo ( k, v ) values ( 2147483647, 'max' );
> INSERT 0 1
> test=# insert into foo ( v ) values ( 'a' ) ;
> INSERT 0 1
> test=# select * from foo;
> 2147483647 | max
> 1 | a
>
> test=#
>
> So, for a "serial" column with 2147483647 in it, I got 1 for the next
> value inserted. I read your example to find out what you were doing
> different and then went back to the postgres manual. What I see is that
> "serial" is not the same thing as auto-increment -- it is different
> thing entirely that you can use instead of auto-increment in some cases.
> That is important to know, but was not immediately obvious to me from
> what I have read so far.

Actually, it is the same thing. A SERIAL or BIGSERIAL type is just a
macro that sets up an auto-increment field.

>
>

>
> Mark S.
>
>

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Browse psycopg by date

  From Date Subject
Next Message Karsten Hilbert 2011-04-08 21:51:28 Re: portable DBAPI auto-increment
Previous Message Mark Sienkiewicz 2011-04-08 17:43:28 Re: portable DBAPI auto-increment