Discussion in 'General DBA Questions' started by LordSlayer, Apr 24, 2003.
Is it OK to have a view with exactly the same name as a table in the same DB?
No. At least I'll try many times without exit.
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)
Practically we'd faced lot of troubles being same name for a Table & View.
Separate names with a comma.