Does updating view updates the table?
-
Hi all, I am facing a helllot of problems with views.. I created a view as create view viewname as select * from tabel1; but when i run an update query on the view , it updates it in the tabel1 tooooo:confused::confused: any help guys????
A view provides a way of looking at the data in a table or tables. A view holds no data in its own right, it simply represents a cached SQL SELECT statement that returns data from the underlying tables. A simple view like yours is updateable, because each row in the view can be mapped back to a row in the underlying table tabel1. This means that you can run insert/update/delete queries on the view as if it was a real table. BTW, it's table, not tabel.
Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush
-
A view provides a way of looking at the data in a table or tables. A view holds no data in its own right, it simply represents a cached SQL SELECT statement that returns data from the underlying tables. A simple view like yours is updateable, because each row in the view can be mapped back to a row in the underlying table tabel1. This means that you can run insert/update/delete queries on the view as if it was a real table. BTW, it's table, not tabel.
Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush
-
Hi all, I am facing a helllot of problems with views.. I created a view as create view viewname as select * from tabel1; but when i run an update query on the view , it updates it in the tabel1 tooooo:confused::confused: any help guys????
My understanding was that views are not updatable in Microsoft SQL Server, unless you use an INSTEAD OF trigger to perform the updates on the base table. Please post the exact version of the exact database server software that you're using with your questions. It saves a lot of time.
DoEvents: Generating unexpected recursion since 1991
-
pmarfleet wrote:
BTW, it's table, not tabel.
oh... sorry it was a typo. So how do i create a view such that the actual data is not altered. I mean if i wan`t to test some queries on data. This is an ideal situation in online databases :-\
newbie.net wrote:
So how do i create a view such that the actual data is not altered. I mean if i wan`t to test some queries on data.
I don't understand. How can you test an UPDATE query if you're not able to update any data? In a typical software development setup, you would have a development environment that is separate from your production environment. Testing of code can be performed in the development environment without compromising the running of the production environment. Your development environment should replicate your production environment as closely as possible. This way, when you move your application from development to production it should behave predictably.
Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush
-
My understanding was that views are not updatable in Microsoft SQL Server, unless you use an INSTEAD OF trigger to perform the updates on the base table. Please post the exact version of the exact database server software that you're using with your questions. It saves a lot of time.
DoEvents: Generating unexpected recursion since 1991
Mike Dimmick wrote:
My understanding was that views are not updatable in Microsoft SQL Server, unless you use an INSTEAD OF trigger to perform the updates on the base table.
This isn't the case. I was able to run an update query on a simple view. The MSDN documentation states: INSERT, UPDATE, and DELETE statements must also meet certain qualifications before they can reference an updatable view. UPDATE and INSERT statements can reference a view only if the view is updatable and the UPDATE or INSERT statement is written so that it modifies data in only one of the base tables referenced in FROM clause of the view. A DELETE statement can reference only a view that is updatable; the view must also reference exactly one table in its FROM clause. AFAIK, a view is updateable if it returns rows of data that can be directly mapped back to rows of data in the underlying table that contains the fields being updated.
Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush