Re: Copying data from one table to another - how to specify fields?

Поиск
Список
Период
Сортировка
От Andrew Sullivan
Тема Re: Copying data from one table to another - how to specify fields?
Дата
Msg-id 20110309141226.GJ32629@shinkuro.com
обсуждение исходный текст
Ответ на Copying data from one table to another - how to specify fields?  (Alexander Farber <alexander.farber@gmail.com>)
Список pgsql-general
On Wed, Mar 09, 2011 at 02:47:46PM +0100, Alexander Farber wrote:
> I would like to copy these fields from one table:
>
>   select user_id, username, user_email, user_regdate, user_lastvisit
> from phpbb_users where user_id > 50;
>
> into the other (already existing) table:
>
>   select uid, name, mail, created, access from drupal_users;
>

INSERT INTO drupal users (uid, name, mail, created, access)
       SELECT user_id, username, user_email, user_regdate, user_lastvist
         FROM phpbb_users where user_id > 50;

This is sort of like an example on
http://www.postgresql.org/docs/9.0/interactive/sql-insert.html, but
that example uses SELCT *.  Perhaps an additional example would have
helped?  (This is basic SQL, though, and I'm not sure the keyword
manual is the best place for such an example.)

A

--
Andrew Sullivan
ajs@crankycanuck.ca

В списке pgsql-general по дате отправления:

Предыдущее
От: Vibhor Kumar
Дата:
Сообщение: Re: [ADMIN] FW: backup using pg_dump postgreSQL 8.3.8
Следующее
От: Michael Glaesemann
Дата:
Сообщение: Re: Copying data from one table to another - how to specify fields?