duplicating table

Поиск
Список
Период
Сортировка
От Johnson, Shaunn
Тема duplicating table
Дата
Msg-id 73309C2FDD95D11192E60008C7B1D5BB0452DCBC@snt452.corp.bcbsm.com
обсуждение исходный текст
Ответы Re: duplicating table  ("Nick Fankhauser" <nickf@ontko.com>)
Re: duplicating table  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Re: duplicating table  ("Arguile" <arguile@lucentstudios.com>)
Список pgsql-general

Howdy:

I know this will seem silly, but I'm trying to
make a copy of a table with a few modifications.

I have a table like so:

[snip]

 Attribute |       Type        | Modifier
-----------+-------------------+----------
 name      | character varying |
 riskgrp   | character(12)     |
 address   | character varying |
 city      | character varying |
 state     | character varying |
 zip       | character varying |
 pcgname   | character varying |

[/snip]

and i want to create a new table like so:

[snip]
 Attribute |       Type        | Modifier
-----------+-------------------+----------
 name      | character varying |
 riskgrp   | character(12)     |
 address   | character varying |
 address2  | character varying |
 city      | character varying |
 state     | character varying |
 zip       | character varying |
 pcgname   | character varying |
 mailcode  | character(5)      |
[/snip]

I can alter the table to add the two
new columns, but I wanted to know if
I can copy the data from the old table
into the new table and put the column
data in the appropriate places
(leaving column: address2 and mailcode empty)?

I have been trying something like:

[example]

insert into t2_ref_pcg_address
select name,riskgrp,address,,city,state,zi p,pcgname from t_ref_pcg_address;

[/example]

And

[example]

select
name,riskgrp,address,,city,state,zip,pcgname from t_ref_pcg_address into t2_ref_pcg_address;

[/example]

Neither works.

Any suggestions?

Thanks!

-X

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

Предыдущее
От: Andrew Perrin
Дата:
Сообщение: Re: Performance tips
Следующее
От: Jeff Eckermann
Дата:
Сообщение: Re: Performance tips