Wednesday, March 21, 2012

Is the default Owner for an Object always 'dbo' ?

In SQL Server 2005, when creating a TABLE, FUNCTION or PROCEDURE, what
governs who is the owner of the object.
Currently, from personal observation, it seems to be always 'dbo',
regardless of the schema that the object is being created in, or who is doin
g
the creating. Is this true, or are there other factors at play?
With the new seperation of user and schema, is there any advantage to having
objects within a schema owned by different people?"Al" <Al@.discussions.microsoft.com> wrote in message
news:B6C51168-2ACF-4A70-B324-487C8E6E938C@.microsoft.com...
> In SQL Server 2005, when creating a TABLE, FUNCTION or PROCEDURE, what
> governs who is the owner of the object.
> Currently, from personal observation, it seems to be always 'dbo',
> regardless of the schema that the object is being created in, or who is
> doing
> the creating. Is this true, or are there other factors at play?
>
The default owner of an object is the owner of the schema. Not the user per
se, but "SCHEMA OWNER". If you change the owner of the schema all objects
in that schema owned by SCHEMA OWNER will have their ownership transferred.

> With the new seperation of user and schema, is there any advantage to
> having
> objects within a schema owned by different people?
No. I can't think of a scenario where this would be useful. If you want to
have objects owned by other users, give the user a new schema and make them
the owner of the schema.
David|||No, the owner of objects is not always dbo by default... I think it
depends on the permission of the user who is creating the object. If
you are a logged in as a "sysadmin" user, then by default all objects
are owned by dbo. I've had a situation here where some developers were
creating objects and the objects were owned by them, not dbo - I'm not
sure what their permissions where however - good question which I will
investiage.
However, you can can have your developers do this, for example, to
ensure ownership is always dbo:
CREATE TABLE dbo.tablename
Al wrote:
> In SQL Server 2005, when creating a TABLE, FUNCTION or PROCEDURE, what
> governs who is the owner of the object.
> Currently, from personal observation, it seems to be always 'dbo',
> regardless of the schema that the object is being created in, or who is do
ing
> the creating. Is this true, or are there other factors at play?
> With the new seperation of user and schema, is there any advantage to havi
ng
> objects within a schema owned by different people?|||<tootsuite@.gmail.com> wrote in message
news:1161621399.913644.324130@.m73g2000cwd.googlegroups.com...
> No, the owner of objects is not always dbo by default... I think it
> depends on the permission of the user who is creating the object. If
> you are a logged in as a "sysadmin" user, then by default all objects
> are owned by dbo. I've had a situation here where some developers were
> creating objects and the objects were owned by them, not dbo - I'm not
> sure what their permissions where however - good question which I will
> investiage.
> However, you can can have your developers do this, for example, to
> ensure ownership is always dbo:
> CREATE TABLE dbo.tablename
>
This applies only to SQL 2000. Not 2005. Read up on user/schema
seperation.
David

No comments:

Post a Comment