Transfers the ownership of database objects from one owner to another.
alter { object_type | all } [owner.]{object_name | * } modify owner { name_in_db | loginame only login_name } [ preserve permissions ]
table – user tables and proxy tables
view – views
procedure – stored procedures
function – user-defined functions
default – defaults defined separately from the creation of tables
rule – rules
type – user-defined datatypes
encryption key – encryption keys
When specified – all explicitly granted or revoked permissions on the objects are preserved and the grantor of the permissions is changed to the new owner.
For example, Bill granted select permission on table bill_table to Mark with grant option. Mark then granted select permission on table bill_table to John. If the ownership of the table is then transferred to Eric with preserve permissions specified, Mark and John retain their permission on bill_table.
When not specified – all existing explicitly granted and revoked permissions on the objects are removed from the system, and as a result, rows in the sysprotects table that correspond to the object are deleted.
Implicit permissions on objects are not preserved for previous owners. New owners acquire all implicit permissions.
For example, Bill is the owner of bill_table and possesses the implicit alter, delete, insert, references, select, and update permissions and explicit decrypt permission on bill_table. After an ownership transfer to Eric with preserve permission specified, Bill only retains decrypt permission on bill_table.
alter table bill.author modify owner eric
alter view bill.vw_author_in_ca modify owner eric preserve permissions
alter table bill.* modify owner eric
alter all bill.* modify owner eric
alter table bill.publisher modify owner cindy
alter procedure bill.publisher
modify owner cindy
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.
Defaults
Decrypt defaults
Dheck constraints
Reference constraints
Partition constraints
Computer columns
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.
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.
ANSI SQL – Compliance level: Transact-SQL extension.
The permission checks for alter... modify owner differ based on your granular permissions settings.
Setting | Description |
---|---|
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:
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:
|
Values in event and extrainfo columns of sysaudits are:
Information | Values |
---|---|
Event | 124 |
Audit option | alter |
Command or access audited | alter .. modify owner |
Information in extrainfo |
|