DB2 10.5 for Linux, UNIX, and Windows

TRANSFER OWNERSHIP statement

The TRANSFER OWNERSHIP statement transfers ownership of a database object.

Invocation

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).

Authorization

The privileges held by the authorization ID of the statement must include at least one of the following authorities:
  • Ownership of the object
  • SECADM authority

Syntax

Read syntax diagramSkip visual syntax diagram
>>-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--------------'   

Description

alias-designator
ALIAS alias-name
Identifies the alias that is to have its ownership transferred. The alias-name must identify an alias that is described in the catalog (SQLSTATE 42704). If PUBLIC is specified, the alias-name must identify a public alias that exists at the current server (SQLSTATE 42704).
FOR TABLE, or FOR SEQUENCE
Specifies the object type for the alias.
FOR TABLE
The alias is for a table, view, or nickname. When ownership of the alias is transferred, the value in the OWNER column for the alias in the SYSCAT.TABLES catalog view is replaced with the authorization ID of the new owner.
FOR SEQUENCE
The alias is for a sequence. When ownership of the alias is transferred, the value in the OWNER column for the alias in the SYSCAT.SEQUENCES catalog view is replaced with the authorization ID of the new owner.
CONSTRAINT table-name.constraint-name
Identifies the constraint that is to have its ownership transferred. The table-name.constraint-name combination must identify a constraint and the table that it constrains. The constraint-name must identify a constraint that is described in the catalog (SQLSTATE 42704).
When ownership of the constraint is transferred, the value in the OWNER column for the constraint in the SYSCAT.TABCONST catalog view is replaced with the authorization ID of the new owner.
  • If the constraint is a FOREIGN KEY constraint, the OWNER column in the SYSCAT.REFERENCES catalog view is replaced with the authorization ID of the new owner.
  • If the constraint is a PRIMARY KEY or UNIQUE constraint, the OWNER column in the SYSCAT.INDEXES catalog view for the index that was created implicitly for this constraint is replaced with the authorization ID of the new owner. If the index existed, and it is reused in this case, the owner of the index is not changed.
DATABASE PARTITION GROUP db-partition-group-name
Identifies the database partition group that is to have its ownership transferred. The db-partition-group-name must identify a database partition group that is described in the catalog (SQLSTATE 42704).

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.

EVENT MONITOR event-monitor-name
Identifies the event monitor that is to have its ownership transferred. The event-monitor-name must identify an event monitor that is described in the catalog (SQLSTATE 42704).

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.

function-designator
Identifies the function that is to have its ownership transferred. For more information, see Function, method, and procedure designators. The specified function instance must be a user-defined function or function template that is described in the catalog. Ownership of functions that are implicitly generated by CREATE TYPE statements cannot be transferred (SQLSTATE 429BT).

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.

SPECIFIC FUNCTION specific-name
Identifies the particular user-defined function that is to have its ownership transferred, using the specific name either specified or defaulted to at function creation time. 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. The specific-name must identify a specific function instance in the named or implied schema; otherwise, an error is returned (SQLSTATE 42704).

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.

FUNCTION MAPPING function-mapping-name
Identifies the function mapping that is to have its ownership transferred. The function-mapping-name must identify a function mapping that is described in the catalog (SQLSTATE 42704).

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.

INDEX index-name
Identifies the index or index specification that is to have its ownership transferred. The index-name must identify an index or index specification that is described in the catalog (SQLSTATE 42704).

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).

INDEX EXTENSION index-extension-name
Identifies the index extension that is to have its ownership transferred. The index-extension-name must identify an index extension that is described in the catalog (SQLSTATE 42704).

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.

method-designator
Identifies the method that is to have its ownership transferred. For more information, see Function, method, and procedure designators. The method body specified must be a method that is described in the catalog (SQLSTATE 42704). The ownership of methods that are implicitly generated by the CREATE TYPE statement cannot be transferred (SQLSTATE 429BT).

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.

NICKNAME nickname
Identifies the nickname that is to have its ownership transferred. The nickname must be a nickname that is described in the catalog (SQLSTATE 42704).

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.

PACKAGE package-name
Identifies the package that is to have its ownership transferred. The package name must identify a package that is described in the catalog (SQLSTATE 42704).
VERSION version-id
Identifies which package version is to have its ownership transferred. If a value is not specified, the version defaults to the empty string, and the ownership of this package is transferred. If multiple packages with the same package name but different versions exist, only the ownership of the package whose version-id is specified in the TRANSFER OWNERSHIP statement is transferred. Delimit the version identifier with double quotation marks when it:
  • Is generated by the VERSION(AUTO) precompiler option
  • Begins with a digit
  • Contains lowercase or mixed-case letters
If the statement is invoked from an operating system command prompt, precede each double quotation mark delimiter with a back slash character to ensure that the operating system does not strip the delimiters.

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).

procedure-designator
Identifies the procedure that is to have its ownership transferred. For more information, see Function, method, and procedure designators. The procedure instance specified must be a procedure that is described in the catalog.

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.

SPECIFIC PROCEDURE specific-name
Identifies the particular procedure that is to have its ownership transferred, using the specific name either specified or defaulted to at procedure creation time. 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. The specific-name must identify a specific procedure instance in the named or implied schema; otherwise, an error is returned (SQLSTATE 42704).

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.

SCHEMA schema-name
Identifies the schema that is to have its ownership transferred. The schema-name must identify a schema that is described in the catalog (SQLSTATE 42704).

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).

SEQUENCE sequence-name
Identifies the sequence that is to have its ownership transferred. The sequence-name must identify a sequence that is described in the catalog (SQLSTATE 42704).

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.

TABLE table-name
Identifies the table that is to have its ownership transferred. The table-name must identify a table that exists in the database (SQLSTATE 42704) and must not identify a declared temporary table (SQLSTATE 42995).
When ownership of the table is transferred:
  • The value in the OWNER column for the table in the SYSCAT.TABLES catalog view is replaced with the authorization ID of the new owner.
  • The value in the OWNER column for all dependent objects on the table in the SYSCAT.TABDEP 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.

TABLE HIERARCHY root-table-name
Identifies the typed table that is the root table in a typed table hierarchy that is to have its ownership transferred. The root-table-name must identify a typed table that is the root table in the typed table hierarchy (SQLSTATE 428DR), and must refer to a typed table that exists in the database (SQLSTATE 42704).
When ownership of the table hierarchy is transferred:
  • The value in the OWNER column for the root table and all of its subtables in the SYSCAT.TABLES catalog view is replaced with the authorization ID of the new owner.
  • The value in the OWNER column for all dependent objects on the table and all of its subtables in the SYSCAT.TABDEP catalog view is replaced with the authorization ID of the new owner.
TABLESPACE tablespace-name
Identifies the table space that is to have its ownership transferred. The tablespace-name must identify a table space that is described in the catalog (SQLSTATE 42704).

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.

TRIGGER trigger-name
Identifies the trigger that is to have its ownership transferred. The trigger-name must identify a trigger that is described in the catalog (SQLSTATE 42704).

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.

TYPE type-name
Identifies the user-defined type that is to have its ownership transferred. The type-name must identify a type that is described in the catalog (SQLSTATE 42704). If DISTINCT is specified, type-name must identify a distinct type that is described in the catalog (SQLSTATE 42704).

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.

TYPE MAPPING type-mapping-name
Identifies the user-defined data type mapping that is to have its ownership transferred. The type-mapping-name must identify a data type mapping that is described in the catalog (SQLSTATE 42704).

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.

VARIABLE variable-name
Indicates that the object whose ownership is to be transferred is a created global variable. The variable-name must identify a global variable that exists at the current server (SQLSTATE 42704).

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.

VIEW view-name
Identifies the view that is to have its ownership transferred. The view-name must identify a view that exists in the database (SQLSTATE 42704).
When ownership of the view is transferred:
  • The value in the OWNER column for the view in the SYSCAT.VIEWS catalog view is replaced with the authorization ID of the new owner.
  • The value in the OWNER column for all dependent objects on the view in the SYSCAT.TABDEP 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).

VIEW HIERARCHY root-view-name
Identifies the typed view that is the root view in a typed view hierarchy that is to have its ownership transferred. The root-view-name must identify a typed view that is the root view in the typed view hierarchy (SQLSTATE 428DR), and must refer to a typed view that exists in the database (SQLSTATE 42704).
When ownership of the view hierarchy is transferred:
  • The value in the OWNER column for the root view and all of its subviews in the SYSCAT.VIEWS catalog view is replaced with the authorization ID of the new owner.
  • The value in the OWNER column for all dependent objects on the view and all of its subviews in the SYSCAT.TABDEP catalog view is replaced with the authorization ID of the new owner.
XSROBJECT xsrobject-name
Identifies the XSR object that is to have its ownership transferred. The xsrobject-name must identify an XSR object that is described in the catalog (SQLSTATE 42704).

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.

USER authorization-name
Specifies the authorization ID to which ownership of the object is being transferred.
SESSION_USER
Specifies that the value of the SESSION_USER special register is to be used as the authorization ID to which ownership of the object is being transferred.
SYSTEM_USER
Specifies that the value of the SYSTEM_USER special register is to be used as the authorization ID to which ownership of the object is being transferred.
PRESERVE PRIVILEGES
Specifies that the current owner of an object that is to have its ownership transferred will continue to hold any existing privileges on the object after the transfer. For example, any privileges that were granted to the creator of a view when that view was created continue to be held by the original owner even after ownership has been transferred to another user.

Rules

Notes

Examples