There are four levels in the naming convention for any SQL Server object
[ServerName.[DatabaseName.[SchemaName.]]]ObjectName
Schema Name (or Ownership)
--the object created is assigned to a schema rather than an owner. Whereas an owner related to one particular login, a schema can now be shared across multiple logins, and one login can have rights to multiple schemas
--For object not belonging to default schema state, use the schema name of your object.
The Default Schema: dbo:::::::::::::::::::::::::::::
--for user of a database MySchema(login name) a table my.table created will have a ownerqualified object name would be MySchema.MyTable. So to access this table we need to use the name MySchema.MyTable (as this is created by a user)
--for database owner fred, a table created as myTable , ownerqualified object name would be dbo.MyTable.
****as dbo also happens to be the default owner, any user could just refer to the table as MyTable.
--sa (sysadmin role)will always have full access as if it were the dbo, and any objects created by the sa login will show ownership belonging to the dbo.
for users the schema will nt default to dbo as the default schema—they will be assigned to whatever that particular user has set as the default schema
Database:::::::::::::::::::::::::::::::
--if you were logged in with AdventureWorks as your current database, and you wanted to refer to the Orders table in the Northwind database, then you could refer to it by Northwind.dbo.Orders or Northwind..Orders as dbo is default schema.
--If a schema named MySchema owns a table named MyTable in MyDatabase, then you could refer to that table as MyDatabase.MySchema.MyTable.
Comments
Post a Comment