Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Does updating view updates the table?

Does updating view updates the table?

Scheduled Pinned Locked Moved Database
databasehelpquestionannouncement
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NetBot
    wrote on last edited by
    #1

    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????

    P M 2 Replies Last reply
    0
    • N NetBot

      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????

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      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

      N 1 Reply Last reply
      0
      • P pmarfleet

        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

        N Offline
        N Offline
        NetBot
        wrote on last edited by
        #3

        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 :-\

        P 1 Reply Last reply
        0
        • N NetBot

          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????

          M Offline
          M Offline
          Mike Dimmick
          wrote on last edited by
          #4

          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

          P 1 Reply Last reply
          0
          • N NetBot

            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 :-\

            P Offline
            P Offline
            pmarfleet
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • M Mike Dimmick

              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

              P Offline
              P Offline
              pmarfleet
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups