using views, abstracting actual tables, updating multiple tables using views
can a single view be used to insert data into three tables simultaneously. am using view to abstract my database actual tables from the end users to开发者_如何转开发 directly insert data into them. the view would act as a protection layer for my actual tables. but i have 3 tables and want to insert data in them.
but since a view can't be used to modify multiple tables. so whats the solution for this?
do i need to create 3 separate views and run :
Insert into View1 values()
Insert into View2 values()
Insert into View3 values()
If you're wanting to update multiple tables from a single view, you'll probably have to create one or more* INSTEAD OF
triggers on the view. You can then use the inserted
and deleted
pseudo tables to craft the insert/update/deletes that should be applied to each of the base tables.
*If there's a lot of commonality between what you're doing for insert and update against the view, I'd recommend a single trigger for both. If the operations are quite different, I'd recommend keeping the triggers separate.
精彩评论