alter...modify owner

Transfers the ownership of database objects from one owner to another.

Syntax

alter { object_type | all } [owner.]{object_name | * }
	modify owner
	{ name_in_db | loginame only login_name } 
	[ preserve permissions ] 

Parameters

Examples

Usage

The ownership of the following dependant objects is implicitly transferred when the ownership of the objects they depend on have been transferred:
  • trigger – ownership of triggers are updated along with the dependent table when the owners are the same. The ownership of a DBO owned trigger cannot be altered if the trigger was created for a non DBO owned table or view.

  • Declarative objects, which are defined during the table or view creation.
    • Defaults

    • Decrypt defaults

    • Dheck constraints

    • Reference constraints

    • Partition constraints

    • Computer columns

When transferring ownership of objects:
  • Use caution in the following system databases: sybsecurity, sybsystemdb, model, sybsystemprocs, sybsyntax, dbccdb, and tempdb.

  • Do not transfer ownership of system objects supplied and managed by SAP, such as but not limited to, user tables with spt_ prefix, system stored procedures with the sp_ prefix, and monitor tables. Doing so can render the system database unusable.

When transferring encryption keys:
  • To an owner who owns a copy of the key is not allowed and the command fails.

  • Changing the owner of encryption keys does not effect the assignees of the encryption key copies.

You cannot use the alter ... modify owner command to change the owner of a precomputed result set. To change the owner, drop the precomputed result set and re-create with the new owner.

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

The permission checks for alter... modify owner differ based on your granular permissions settings.

SettingDescription
Enabled

With granular permissions enabled, you must have the alter any object owner privilege for objects other than encryption key.

Only encryption key owners or user with the following privilege (based on encryption key type) can transfer the encryption key ownership:

  • column encryption key – manage column encryption key

  • master key – manage master key

  • service key – manage service key

The database users (with alter any object owner privilege) who are explicitly or implicitly aliased to the database owner are not allowed to transfer the ownership of objects they concretely own. An object is identified as concretely owned by the database owner if it includes database owner user ID for the value of sysobjects.uid, and NULL or the database owner’s login name for the value of sysobjects.loginame.

Disabled
With granular permissions disabled:
  • System security officer (SSO) users are allowed to use this command to transfer the ownership of objects.

  • Only SSO users and encryption key owners can transfer the encryption key ownership.

  • Database owner (DBO) users and users who are explicitly or implicitly aliased to the DBO are allowed to transfer the ownership of objects with a type other than encryption keys with the following restrictions:
    • Database owners are not allowed to transfer the ownership of objects they concretely own. An object is identified as concretely owned by the database owner if it includes DBO_UID for the value of sysobjects.uid, and NULL or the database owner’s login name for the value of sysobjects.loginame.

    • The functionality of transferring the ownership of multiple objects in one command is disabled for safety reasons and the transfer of DBO objects must be in the form of dbo.object_name.

Auditing

Values in event and extrainfo columns of sysaudits are:

InformationValues
Event

124

Audit option

alter

Command or access audited

alter .. modify owner

Information in extrainfo
  • Roles – current active roles

  • Keywords or options – one of:
    • USER TYPE owner.obj_name – if you are changing user-defined types’ ownership

    • NEW OWNERname_in_db

    • PRESERVE PERMISSIONS – if the option is specified

    • NEW LOGINAMElogin_name, if LOGINAME ONLY login_name is specified

  • Previous value – NULL

  • Current value – NULL

  • Other information – NULL

  • Proxy information – original login name, if set proxy is in effect