SQL Server Performance

same name for table and view

Discussion in 'General DBA Questions' started by LordSlayer, Apr 24, 2003.

  1. LordSlayer New Member

    Is it OK to have a view with exactly the same name as a table in the same DB?

    lp john
  2. Luis Martin Moderator

    John:

    No. At least I'll try many times without exit.

    Luis
  3. satya Moderator

    Precisly no.

    _________
    Satya SKJ
  4. Chappy New Member

    Well, thats not strictly true. A view can have the same name as a table as long as it doesnt have the same owner.

    So if you had a table called Sales owned by dbo, you could create a view (with user1 as the owner) on dbo.Sales and called it Sales also.

    if a user was logged in as user1 and you then query the table/view, without fully qualifying the table name, he would select from the user1.Sales view.

    If he wanted to select from the Sales table, he would need to qualify the object name, and 'select * from dbo.Sales'

    Having said that, its quite confusing working with a design of this nature. I recommend you try to find another way (vwSales_user01, vwSales_user02 etc) would be my way of naming it)

  5. satya Moderator

    Practically we'd faced lot of troubles being same name for a Table & View.

    _________
    Satya SKJ

Share This Page