Is it possible to create a View with read only option in MySQL?

Viewed 8481

I'm currently having the latest version of MySQL(ver 8.0.2) and I'm trying to create a read-only View.

This is how my query looks like:

CREATE VIEW Emp_Salary3 AS
SELECT Empid, Ename, Date_Joined, Salary, Dcode 
FROM Employees
WHERE Salary < 35000
WITH READ ONLY;

But then the response I got was:

Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'READ ONLY' at line 5

Hence I checked the manual as well, it doesn't have a READ-ONLY option whatsoever. Is there a work around for this?

Any help could be appreciated.

3 Answers

If the view has a join in it, then MYSQL will make that view read only (since it can't update composite views) but its a bit of an extreme measure

Related