Professional Documents
Culture Documents
If the view contains joins between multiple tables, you can only
insert and update one table in the view, and you can't delete
rows.
You can't directly modify data in views based on union queries.
You can't modify data in views that use GROUP
BY or DISTINCT statements.
All columns being modified are subject to the same restrictions as
if the statements were being executed directly against the base
table.
AS
SELECT Categories.CategoryName,
Products.ProductID, Products.ProductName
Categories ON
Products.CategoryID = Categories.CategoryID
This UPDATE statement will also work because only affects the
Categories table's side of the join:
UPDATE vwCategoriesProducts
WHERE ProductID = 1
UPDATE vwCategoriesProducts
SET ProductName = 'Chay', CategoryName = 'Drinks'
WHERE ProductID = 1
Updating a view changes data in master table
select * from a;
update a1view
set emp_name = 'THOMAS'
where emp_id = 1;
select * from a;
To ensure the consistency of the view, you use the WITH CHECK
OPTION clause when you create or modify the view.
The WITH CHECK OPTION clause prevents you from updating or
inserting rows that are not visible through the view.
Example:
CREATE OR REPLACE VIEW a_det
AS
update a_det
set emp_name = 'ORACLE'
where manager_id = 3;
FORCE VIEW