The TRANSFER OWNERSHIP statement transfers ownership of a database object.
This statement can be embedded in an application program or issued through the use of dynamic SQL statements. It is an executable statement that can be dynamically prepared only if DYNAMICRULES run behavior is in effect for the package (SQLSTATE 42509).
>>-TRANSFER OWNERSHIP OF--| objects |--TO--| new-owner |--------> >--PRESERVE PRIVILEGES----------------------------------------->< objects |--+-| alias-designator |-------------------------------+-------| +-CONSTRAINT--table-name.constraint-name-------------+ +-DATABASE PARTITION GROUP--db-partition-group-name--+ +-EVENT MONITOR--event-monitor-name------------------+ +-| function-designator |----------------------------+ +-FUNCTION MAPPING--function-mapping-name------------+ +-INDEX--index-name----------------------------------+ +-INDEX EXTENSION--index-extension-name--------------+ +-| method-designator |------------------------------+ +-NICKNAME--nickname---------------------------------+ +-PACKAGE--package-name--+-------------------------+-+ | | .-VERSION-. | | | '-+---------+--version-id-' | +-| procedure-designator |---------------------------+ +-SCHEMA--schema-name--------------------------------+ +-SEQUENCE--sequence-name----------------------------+ +-TABLE--table-name----------------------------------+ +-TABLE HIERARCHY--root-table-name-------------------+ +-TABLESPACE--tablespace-name------------------------+ +-TRIGGER--trigger-name------------------------------+ +-+----------+--TYPE--type-name----------------------+ | '-DISTINCT-' | +-TYPE MAPPING--type-mapping-name--------------------+ +-VARIABLE--variable-name----------------------------+ +-VIEW--view-name------------------------------------+ +-VIEW HIERARCHY--root-view-name---------------------+ '-XSROBJECT--xsrobject-name--------------------------' alias-designator .-FOR TABLE----. |--+--------+--ALIAS--alias-name--+--------------+--------------| '-PUBLIC-' '-FOR SEQUENCE-' function-designator |--+-FUNCTION--function-name--+-------------------------+-+-----| | '-(--+---------------+--)-' | | | .-,---------. | | | | V | | | | '---data-type-+-' | '-SPECIFIC FUNCTION--specific-name---------------------' method-designator |--+-METHOD--method-name--+-------------------------+--FOR--type-name-+--| | '-(--+---------------+--)-' | | | .-,---------. | | | | V | | | | '---data-type-+-' | '-SPECIFIC METHOD--specific-name-----------------------------------' procedure-designator |--+-PROCEDURE--procedure-name--+-------------------------+-+---| | '-(--+---------------+--)-' | | | .-,---------. | | | | V | | | | '---data-type-+-' | '-SPECIFIC PROCEDURE--specific-name----------------------' new-owner |--+-USER--authorization-name-+---------------------------------| +-SESSION_USER-------------+ '-SYSTEM_USER--------------'
When ownership of the database partition group is transferred, the value in the OWNER column for the database partition group in the SYSCAT.DBPARTITIONGROUPS catalog view is replaced with the authorization ID of the new owner.
When ownership of the event monitor is transferred, the value in the OWNER column for the event monitor in the SYSCAT.EVENTMONITORS catalog view is replaced with the authorization ID of the new owner.
If the identified event monitor is active, an error is returned (SQLSTATE 429BT).
If there are event files in the target path of a WRITE TO FILE event monitor whose ownership is being transferred, the event files are not deleted.
When ownership of WRITE TO TABLE event monitors is transferred, table information in the SYSCAT.EVENTTABLES catalog view is retained.
When ownership of the function is transferred, the value in the OWNER column for the function in the SYSCAT.ROUTINES catalog view is replaced with the authorization ID of the new owner. Transferring ownership of an SQL function that has an associated package also implicitly transfers ownership of the package to the new owner.
When ownership of the specific function is transferred, the value in the OWNER column for the specific function in the SYSCAT.ROUTINES catalog view is replaced with the authorization ID of the new owner.
When ownership of the function mapping is transferred, the value in the OWNER column for the function mapping in the SYSCAT.FUNCMAPPINGS catalog view is replaced with the authorization ID of the new owner.
When ownership of the index is transferred, the value in the OWNER column for the index in the SYSCAT.INDEXES catalog view is replaced with the authorization ID of the new owner.
Ownership of an index cannot be transferred if the table on which the index is defined is a global temporary table (SQLSTATE 429BT).
When ownership of the index extension is transferred, the value in the OWNER column for the index extension in the SYSCAT.INDEXEXTENSIONS catalog view is replaced with the authorization ID of the new owner.
When ownership of the method is transferred, the value in the OWNER column for the method in the SYSCAT.ROUTINES catalog view is replaced with the authorization ID of the new owner.
When ownership of the nickname is transferred, the value in the OWNER column for the nickname in the SYSCAT.TABLES catalog view is replaced with the authorization ID of the new owner.
When ownership of the package is transferred, the value in the BOUNDBY column for the package in the SYSCAT.PACKAGES catalog view is replaced with the authorization ID of the new owner.
The ownership of packages that are associated with SQL procedures, compiled SQL functions or compiled triggers cannot be transferred (SQLSTATE 429BT).
When ownership of the procedure is transferred, the value in the OWNER column for the procedure in the SYSCAT.ROUTINES catalog view is replaced with the authorization ID of the new owner.
Transferring ownership of an SQL procedure that has an associated package also implicitly transfers ownership of the package to the new owner.
When ownership of the specific procedure is transferred, the value in the OWNER column for the specific procedure in the SYSCAT.ROUTINES catalog view is replaced with the authorization ID of the new owner.
When ownership of the schema is transferred, the value in the OWNER column and the DEFINER column for the schema in the SYSCAT.SCHEMATA catalog view is replaced with the authorization ID of the new owner.
Ownership of built-in schemas (where the definer is SYSIBM) cannot be transferred (SQLSTATE 42832).
When ownership of the sequence is transferred, the value in the OWNER column for the schema in the SYSCAT.SEQUENCES catalog view is replaced with the authorization ID of the new owner.
Ownership of subtables in a table hierarchy cannot be transferred (SQLSTATE 429BT).
In a federated system, ownership of a remote table that was created using transparent DDL can be transferred. Transferring the ownership of a remote table will not transfer ownership of the nickname that is associated with the table. Ownership of such a nickname can be transferred explicitly using the TRANSFER OWNERSHIP statement.
When ownership of the table space is transferred, the value in the OWNER column for the table space in the SYSCAT.TABLESPACES catalog view is replaced with the authorization ID of the new owner.
When ownership of the trigger is transferred, the value in the OWNER column for the trigger in the SYSCAT.TRIGGERS catalog view is replaced with the authorization ID of the new owner. Transferring ownership of a compiled trigger also implicitly transfers ownership of the associated package to the new owner.
In dynamic SQL statements, the CURRENT SCHEMA special register is used as a qualifier for an unqualified object name. In static SQL statements, the QUALIFIER precompile or bind option implicitly specifies the qualifier for unqualified object names.
When ownership of the type is transferred, the value in the OWNER column for the type in the SYSCAT.DATATYPES catalog view is replaced with the authorization ID of the new owner.
When ownership of the type mapping is transferred, the value in the OWNER column for the type mapping in the SYSCAT.TYPEMAPPINGS catalog view is replaced with the authorization ID of the new owner.
When the global variable is transferred, the value in the OWNER column for the global variable in the SYSCAT.VARIABLES catalog view is replaced with the authorization ID of the new owner.
The ownership of a subview in a view hierarchy cannot be transferred (SQLSTATE 429BT).
When ownership of the XSR object is transferred, the value in the OWNER column for the XSR object in the SYSCAT.XSROBJECTS catalog view is replaced with the authorization ID of the new owner.
Database Object | Catalog View |
---|---|
CONSTRAINT | SYSCAT.CONSTDEP |
FUNCTION | SYSCAT.ROUTINEDEP; SYSCAT.ROUTINES (for a sourced function) |
INDEX | SYSCAT.INDEXDEP |
INDEX EXTENSION | SYSCAT.INDEXEXTENSIONDEP |
METHOD | SYSCAT.ROUTINEDEP |
PACKAGE | SYSCAT.PACKAGEDEP |
PROCEDURE | SYSCAT.ROUTINEDEP |
TABLE | SYSCAT.TABDEP |
TRIGGER | SYSCAT.TRIGDEP |
VIEW | SYSCAT.TABDEP |
XSROBJECT | SYSCAT.XSROBJECTDEP |
TRANSFER OWNERSHIP OF TABLE WALID.T1
TO USER PAUL PRESERVE PRIVILEGES
The
value in the OWNER column for the table WALID.T1 in the SYSCAT.TABLES
catalog view is replaced with 'PAUL'. Paul is implicitly granted the
following privileges on table WALID.T1 (assuming that the previous
owner of the table did not lose any privileges on it): CONTROL and
ALTER, DELETE, INDEX, INSERT, SELECT, UPDATE, REFERENCE (WITH GRANT
OPTION). TRANSFER OWNERSHIP OF VIEW V1
TO USER HENRY PRESERVE PRIVILEGES
The
value in the OWNER column for the view V1 in the SYSCAT.VIEWS catalog
view is replaced with 'HENRY'. A new row is added to SYSCAT.TABAUTH
with the following values: GRANTOR = 'SYSIBM', GRANTEE = 'HENRY',
and TABNAME = 'V1'. TRANSFER OWNERSHIP OF TRIGGER TR1
TO USER WALID PRESERVE PRIVILEGES
Ownership
of the trigger is transferred successfully, even though Walid does
not hold DBADM authority. TRANSFER OWNERSHIP OF VIEW V1
TO USER PAUL PRESERVE PRIVILEGES
Ownership
of the view is transferred successfully, even though Paul does not
hold CONTROL privilege on table JOHN.T2. Paul only needs SELECT privilege
on tables JOHN.T1 and JOHN.T2 to maintain the view's existence. (The
view only has SELECT privilege because Paul did not hold CONTROL privilege
on both tables when the view was created and, as a result, he was
not granted CONTROL on the view.) The value in the OWNER column for
the view V1 in the SYSCAT.VIEWS catalog view is replaced with 'PAUL'.
The value in the OWNER column for the view V1 in the SYSCAT.TABDEP
catalog view is replaced with 'PAUL'. A new row is added to SYSCAT.TABAUTH
with the following values: GRANTOR = 'SYSIBM', GRANTEE = 'PAUL', and
TABNAME = 'V1'. TRANSFER OWNERSHIP OF VIEW V1
TO USER MIKE PRESERVE PRIVILEGES
Ownership
of the view is transferred successfully, because Mike holds SELECT
privilege on table JOHN.T1 through PUBLIC. The value in the OWNER
column for the view V1 in the SYSCAT.VIEWS catalog view is replaced
with 'MIKE'. The value in the OWNER column for the view V1 in the
SYSCAT.TABDEP catalog view is replaced with 'MIKE'. A new row is added
to SYSCAT.TABAUTH with the following values: GRANTOR = 'SYSIBM', GRANTEE
= 'MIKE', and TABNAME = 'V1'. TRANSFER OWNERSHIP OF VIEW V1
TO USER MIKE PRESERVE PRIVILEGES
Ownership
of the view is transferred successfully, because Mike holds SELECT
privilege on table JOHN.T1 through membership in role R1. The value
in the OWNER column for the view V1 in the SYSCAT.VIEWS catalog view
is replaced with 'MIKE'. The value in the OWNER column for the view
V1 in the SYSCAT.TABDEP catalog view is replaced with 'MIKE'. A new
row is added to SYSCAT.TABAUTH with the following values: GRANTOR
= 'SYSIBM', GRANTEE = 'MIKE', and TABNAME = 'V1'.