Re: portable DBAPI auto-increment - Mailing list psycopg

From Adrian Klaver
Subject Re: portable DBAPI auto-increment
Date
Msg-id 4D9F4F59.50701@gmail.com
Whole thread Raw
In response to Re: portable DBAPI auto-increment  (Mark Sienkiewicz <sienkiew@stsci.edu>)
List 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.klaver@gmail.com

psycopg by date:

Previous
From: Mark Sienkiewicz
Date:
Subject: Re: portable DBAPI auto-increment
Next
From: Karsten Hilbert
Date:
Subject: Re: portable DBAPI auto-increment