Skip to main content

Can you update data through a view?

Yes, you can update data through a view, but only if it's simple - meaning it's based on a single table and has no complex operations like JOIN, GROUP BY, DISTINCT, SUM(), and the like.

Example: it works

sql
CREATE VIEW user_info AS SELECT id, name, email FROM users; UPDATE user_info SET email = 'new@mail.com' WHERE id = 3;

The change goes through, the record in the users table gets updated.

But if a view combines several tables (JOIN) or uses computations, the database can't tell exactly where to update the data - and the operation fails.

So: simple VIEWs can be updated, complex ones can only be read.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.