On Wednesday, June 08, 2011 1:40:35 pm David Johnston wrote: > > -----Original Message----- > > From: Mike Christensen [mailto:mike@xxxxxxxxxxxxx] > > Sent: Wednesday, June 08, 2011 4:26 PM > > To: David Johnston; pgsql-general@xxxxxxxxxxxxxx > > Subject: Re: 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.klaver@xxxxxxxxx |