Re: [GENERAL] How to drop column from interrelated views

Поиск
Список
Период
Сортировка
От Berend Tober
Тема Re: [GENERAL] How to drop column from interrelated views
Дата
Msg-id 0456dfda-4623-1331-7dca-e3cff914357b@computer.org
обсуждение исходный текст
Ответ на [GENERAL] How to drop column from interrelated views  (Guyren Howe <guyren@gmail.com>)
Ответы Re: [GENERAL] How to drop column from interrelated views
Список pgsql-general
Guyren Howe wrote:
> On Jul 8, 2017, at 16:11 , Berend Tober <btober@computer.org <mailto:btober@computer.org>>
> wrote:
>>
>> Guyren Howe wrote:
>>> I’ve a set of interrelated views. I want to drop a column from a table and from all the views
>>> that cascade from it.
>>>
>>> I’ve gone to the leaf dependencies and removed the field from them. But I can’t remove the
>>> field from the intermediate views because Postgres doesn’t appear to be clever enough to see
>>> that the leafs no longer depend on the column. Or did I just miss one?
>>>
>>> In general, this seems like a major weakness expressing a model in Postgres (I get that any
>>> such weakness derives from SQL; that doesn’t stop me wanting a solution).
>>>
>>> Thoughts? Comments?
>>
>> This usually involves a pg_dump in the custom format, editing the list file, creating a script
>> with pg_restore.
>>
>> I described a way I have had success with it at one point at
>>
>>
>> https://www.postgresql.org/message-id/55C3F0B4.5010600%40computer.org
>
> I was wondering if I changed up all the things that interrelate in a transaction, whether that
> would bundle them up so they’re all correct afterward. I was hoping so.


Well, nothing beats empirical evidence ... set up a test case and try it!

You definitely want to do it in a transaction anyway, so that if you get it wrong the first few
times and have to iterate, the data base rolls back to where you started.

Note the method suggested in the earlier link appears to have a error. Step 4 should be


   pg_restore -c -1  -L mydatabase.list mydatabase.dump > sql


The lower case "c" flag will include DROP statements for the views. The "1" will wrap in a
transaction, like you want.


BTW, please generally use the "reply-all" functionality of your email client when interacting with
this list ... the server puts the list alias in the CC line, so you have to reply all to keep the
conversation publicly available for others to learn from.

-- B




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

Предыдущее
От: Berend Tober
Дата:
Сообщение: Re: [GENERAL] How to drop column from interrelated views
Следующее
От: Melvin Davidson
Дата:
Сообщение: Re: [GENERAL] How to drop column from interrelated views