From: | Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Cc: | "David Johnston" <polobo(at)yahoo(dot)com>, "'Mike Christensen'" <mike(at)kitchenpc(dot)com> |
Subject: | Re: Converting uuid primary key column to serial int |
Date: | 2011-06-08 23:54:50 |
Message-ID: | 201106081654.50842.adrian.klaver@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wednesday, June 08, 2011 1:40:35 pm David Johnston wrote:
> > -----Original Message-----
> > From: Mike Christensen [mailto:mike(at)kitchenpc(dot)com]
> > Sent: Wednesday, June 08, 2011 4:26 PM
> > To: David Johnston; pgsql-general(at)postgresql(dot)org
> > Subject: Re: [GENERAL] Converting uuid primary key column to serial int
> >
> >
> > I'm assuming I can still have a "Serial" column that is NOT a primary
> > key,
>
> and
>
> > it'll incremement just the same as I add rows? If that's the case, I
>
> think that's
>
> > a superior approach..
> >
> > BTW, this table is too small to worry about disk space of UUIDs and/or
> > perhaps any sort of performance benefits to using int over uuid (if there
>
> are
>
> > any)..
> >
> > Mike
>
> " CREATE TABLE t ( field serial ); " is simply short-hand for " CREATE
> TABLE t (field integer DEFAULT nextval('t_seq') ); " where the sequence
> "t_seq" is automatically created and linked to the table.
>
Actually per the docs and for completeness sake:
http://www.postgresql.org/docs/9.0/interactive/datatype-numeric.html#DATATYPE-
SERIAL
CREATE SEQUENCE tablename_colname_seq;
CREATE TABLE tablename (
colname integer NOT NULL DEFAULT nextval('tablename_colname_seq')
);
ALTER SEQUENCE tablename_colname_seq OWNED BY tablename.colname;
So the NOT NULL is already included.
>
> David J.
--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2011-06-09 03:46:08 | Re: Best Practices - Securing an Enterprise application using JBOSS & Postgres |
Previous Message | Mike Christensen | 2011-06-08 20:54:45 | Re: Converting uuid primary key column to serial int |