From: | Berend Tober <btober(at)computer(dot)org> |
---|---|
To: | Guyren Howe <guyren(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: How to drop column from interrelated views |
Date: | 2017-07-09 13:56:50 |
Message-ID: | 0456dfda-4623-1331-7dca-e3cff914357b@computer.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Guyren Howe wrote:
> On Jul 8, 2017, at 16:11 , Berend Tober <btober(at)computer(dot)org <mailto:btober(at)computer(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Melvin Davidson | 2017-07-09 15:27:56 | Re: How to drop column from interrelated views |
Previous Message | Berend Tober | 2017-07-08 23:11:45 | Re: How to drop column from interrelated views |