2

I want to drop a view but save dependent views. I just want to update a view's SQL text, but can't do it without deleting it. When I delete it all dependents are deleted. I want to avoid it.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263

1 Answers1

0

You'll have to drop the dependent views if CREATE OR REPLACE VIEW doesn't do the trick.

Views are not saved as text, but as parsed queries.

If you don't have the CREATE VIEW statements handy, you can use pg_dump -s or the pg_get_viewdef database function to generate them on the fly.

I cannot refrain from mentioning that a deeply nested hierarchy of views is in my opinion a recipe for trouble.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263