Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine if a postgres view is updatable

According to the documentation Postgres > CREATE VIEW > Updatable Views , a postgres view is updatable if following set of conditions are met:

The view must have exactly one entry in its FROM list, which must be a table or another updatable view.

The view definition must not contain WITH, DISTINCT, GROUP BY, HAVING, LIMIT, or OFFSET clauses at the top level.

The view definition must not contain set operations (UNION, INTERSECT or EXCEPT) at the top level.

The view's select list must not contain any aggregates, window functions or set-returning functions.

How do I programmatically determine, given a view some_random_view is updatable or not?

like image 718
Naisheel Verdhan Avatar asked Sep 11 '25 22:09

Naisheel Verdhan


1 Answers

The information_schema.views data dictionary view contains the column is_updatable. The contents of this column tells you if the view is updatable or not.

like image 67
steve Avatar answered Sep 13 '25 13:09

steve