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

From: David Salisbury <salisbury(at)globe(dot)gov>
To: pgsql-general(at)postgresql(dot)org
Subject: create table as select... with auto increment id ?
Date: 2011-07-26 00:17:29
Message-ID: 4E2E0799.6080002@globe.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


We all know i can

create table freaky as select "abunchofstuff".

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 ;-<

Thanks for any info,

-Dave

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Geoghegan 2011-07-26 00:45:18 Re: create table as select... with auto increment id ?
Previous Message Craig Ringer 2011-07-25 23:32:46 Re: Tracing in Postgres