Re: create table as select... with auto increment id ?

From: Peter Geoghegan <peter(at)2ndquadrant(dot)com>
To: David Salisbury <salisbury(at)globe(dot)gov>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: create table as select... with auto increment id ?
Date: 2011-07-26 00:45:18
Message-ID: CAEYLb_VZW92gjo_wxHhsOQ3F4RWBArBWiVs49wTeajRZxR9qSw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 26 July 2011 01:17, David Salisbury <salisbury(at)globe(dot)gov> wrote:
> I work with rails developers and they are fussy about having an
> auto incrementing "id" field.  Is there a way I can eak that out
> of the above type statement, or am I stuck with creating the
> table and no short cuts?
>
> create table freaky ( id autoincrement, and-a-long-list int,
> and-perfect-order float )
> insert into freaky as select "abunchofstuff-in-same-order"
>
> I think I know the answer ;-<

http://wiki.postgresql.org/wiki/FAQ#How_do_I_create_a_serial.2Fauto-incrementing_field.3F

Hope that helps

--
Peter Geoghegan       http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2011-07-26 00:45:35 Re: create table as select... with auto increment id ?
Previous Message David Salisbury 2011-07-26 00:17:29 create table as select... with auto increment id ?