DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: I need to add an surrogate key to a view

Hybrid View

  1. #1
    Join Date
    Apr 2010
    Location
    Indianapolis
    Posts
    11

    I need to add an surrogate key to a view

    All,

    Is this possible to add a column that is a surrogate key to a view.

    What about using the rownum as this surrogate key. any issues or problems to arise?

    thanks,
    Kat
    Last edited by katora; 11-29-2012 at 04:08 PM.

  2. #2
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166
    Row num is not a deterministic function. As in every time that you select from the query the row num value is different for every row. Given that every table should have a primary key, you should be able to find a value or set of values that are always unique. If not, then you need to think about the way in which your database was designed. If this is an aggregate query then you need to group by fewer columns.

    Basically your asking the wrong question. The right question should be why can't I uniquely identify each row based on a unique set of values.

  3. #3
    Join Date
    Apr 2010
    Location
    Indianapolis
    Posts
    11
    ok, thanks I understand what you are saying. I will look at the view again. thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width