I want make change in one view that have dependence view's, so when i try to make change i'm block because of this, what is the best solution??
On Tue, Jan 30, 2018 at 10:12 AM, Melvin Davidson <melvin6925@xxxxxxxxx> wrote:
-- On Tue, Jan 30, 2018 at 12:48 PM, David G. Johnston <david.g.johnston@xxxxxxxxx> wrote:When this procedure got old, I started using a script created using pg_dump and pg_restore, as initially outlined here:Yeah, the short answer is PostgreSQL doesn't make it possible to edit "middle" views without having the code on hand for all dependent views so you can recreate them. You either maintain those views and order manually or you rely on pg_dump to figure it out for you (the former, with version control, is highly recommended).
I agree it's best to keep the definitions of the view yourself--among other things it lets you keep comments. But you can also generate a perfectly-functional definition of a view with \d+.
Just a side note, it is not a good practice to create views based on other views.Multiple reasons are stated here:To summarize, you suffer performance degradation, columns names and the tables referenced become obscured and you incur the problems you are now experiencing.
That link you pointed to includes arguments both for and against. It seems to me that performance weighs against nested views, clarity can cut both ways, and nested views can help centralize and encapsulate business logic, avoiding needs for reuse and maintaining consistency. Whether they are a good idea or not depends on your goals, priorities and specific situation.
Cheers,
Ken
AGENCY Software
A Free Software data system
By and for non-profits
(253) 245-3801
learn more about AGENCY or
follow the discussion.