cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Gentry" <>
Subject Re: PostgreSQL sequences revisited
Date Thu, 02 Aug 2007 12:51:03 GMT
Again, no JDBC info here, but ...

I did (this is all done in PgAdmin):

create table mytable
( name varchar(60), pk serial primary key )

and this was reported:

NOTICE:  CREATE TABLE will create implicit sequence "mytable_pk_seq"
for serial column ""
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"mytable_pkey" for table "mytable"

So I went and looked for the sequence and found:

CREATE SEQUENCE mytable_pk_seq
  MAXVALUE 9223372036854775807
  CACHE 1;

So it did create a sequence for the serial type.  I could then do inserts like:

insert into mytable (name) values ('michael')

and it would increment the values.


On 8/2/07, Michael Gentry <> wrote:
> This doesn't really cover the JDBC driver, but tells a little more
> about the serial type:
> It looks like declaring something to be serial sets up a sequence,
> too?  I'm always wary of the word "equivalent" in tech docs, though.
> I've gotten burned by that before.  (The old NeXTstep documentation
> said calling "new" was the equivalent of "alloc" and then "init" --
> but new didn't call alloc then init.)
> I can create a scratch DB later and see what it does ...
> /dev/mrg

View raw message