I don't think that Postgres provides a way to explicitly define a view as read-onöy.
The documentation states:
Simple views are automatically updatable
However:
A more complex view that does not satisfy all these conditions is read-only by default.
The documentation lists the limitations of read-only views:
A view is automatically updatable if it satisfies all of the following conditions:
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.
Simple views are automatically updatable: the system will allow INSERT, UPDATE and DELETE statements to be used on the view in the same way as on a regular table. A view is automatically updatable if it satisfies all of the following conditions:
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
Unless your view satisfies all conditions, it is read-only. If you have a simple view that you want to make read-only, a (suboptimal) option would be to tweak its definition so it violates one of the above rules.
For example, you can add a dummy WITH
clause:
CREATE VIEW myview AS
WITH dummy AS (SELECT 1)
-- real view definition here