August 2, 2019 at 10:54 pm
I queried sys.tables, sys.all_views, sys.all_objects and . The following appear to be views:
1. tables
2. all_views
3. all_objects
In all 3 of these cases what is the ‘sys’ part? Isn’t that a schema?
I did a SELECT * on all_objects so I can view all objects. I have a few questions about the results of this query:
August 3, 2019 at 8:07 am
The documentation for the all_objects catalog view states that it shows all schema-scoped user-defined objects and system objects. Database-scoped objects that aren't within a specific schema are not included - this includes schemas themselves, database users, roles etc. The types of objects that are included are listed here.
You're correct about the names of schema-scoped objects (table, stored procedures, etc) being only unique within the same schema. I may be wrong on this, but I believe differences in casing doesn't affect uniqueness in the default non case-sensitive collation. Again, it's that schema_id that the names need to be unique within, and checking the sys.schemas view, the two tables objects you've referenced are in the "INFORMATION_SCHEMA" and "sys" schemas.
As an example of having two tables with the same name in the database, these statements execute just fine.
CREATE SCHEMA Costpoint;
GO
CREATE TABLE Costpoint.Employee (
employeeID INT PRIMARY KEY IDENTITY(1,1)
)
CREATE TABLE dbo.Employee (
employeeID INT PRIMARY KEY IDENTITY(1,1)
)
Best,
Andrew
August 4, 2019 at 4:48 pm
Andrew,
What you said makes sense. Thank you for clarifying this. I noticed the SQL documentation mentioned 'schema scoped' but I wasn't sure what that meant. After reading your post I think I understand now.
August 5, 2019 at 6:14 am
This was removed by the editor as SPAM
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply