Re: Example of RETURNING clause to get auto-generated keys from INSERT

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Adam Rich <adam(dot)r(at)sbcglobal(dot)net>
Cc: 'Ken Johanson' <pg-user(at)kensystem(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Example of RETURNING clause to get auto-generated keys from INSERT
Date: 2007-01-24 20:43:02
Message-ID: 20070124204302.GC19495@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Jan 23, 2007 at 23:19:47 -0600,
Adam Rich <adam(dot)r(at)sbcglobal(dot)net> wrote:
>
> And your normal query would be this:
>
> INSERT into mytable (id,value) values (1,"foo"),(2,"bar");
>
> Your new query would be like this:
>
> INSERT into mytable (id,value) values (1,"foo"),(2,"bar")
> RETURNING id;

Note that you will want to be using single quotes not double quotes.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rich Shepard 2007-01-24 21:08:04 Re: Cannot Restart PostgreSQL-8.1.4
Previous Message marcelo Cortez 2007-01-24 20:39:10 Re: capacity of tables