Re: portable DBAPI auto-increment
От | Adrian Klaver |
---|---|
Тема | Re: portable DBAPI auto-increment |
Дата | |
Msg-id | 4D9F4F59.50701@gmail.com обсуждение исходный текст |
Ответ на | Re: portable DBAPI auto-increment (Mark Sienkiewicz <sienkiew@stsci.edu>) |
Список | 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 по дате отправления: