Re: Normalising an existing table - how?

Поиск
Список
Период
Сортировка
От Graham Leggett
Тема Re: Normalising an existing table - how?
Дата
Msg-id 40DB4AD0.8040805@sharp.fm
обсуждение исходный текст
Ответ на Re: Normalising an existing table - how?  ("Phil Endecott" <spam_from_postgresql_sql@chezphil.org>)
Ответы Re: Normalising an existing table - how?
Список pgsql-sql
Phil Endecott wrote:

>>- Select the money column from the table
>>- Populate the new normalised table with each row containing
>>  the value from the original money column
>>- Write the primary keys of the new rows in the normalised
>>  table, back to a new column in the original table added for
>>  this purpose.

> Change the order.  Do the third step first:
> 
> alter table T add column X integer;
> update T set X = nextval(somesequence);
> 
> Now do the first and second steps together:
> 
> select X, MoneyColumn from T into NewTable;
> 
> Is this the sort of thing you need?

I think it is - though the select foo into NewTable part, does NewTable 
have to be empty first, or can it already exist?

In my case NewTable has some rows in it already, as the database is 
currently partially normalised - I need to finish the job.

Regards,
Graham
--


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

Предыдущее
От: Frank Bax
Дата:
Сообщение: Re: Normalising an existing table - how?
Следующее
От: Graham Leggett
Дата:
Сообщение: Re: Normalising an existing table - how?