CREATE USER MAPPING statement - Examples for the ODBC wrapper

Use the CREATE USER MAPPING statement to map a federated server user ID to an ODBC data source user ID and password. This topic provides a complete example with the required parameters, and an example that shows you how to use the Db2® special register USER with the CREATE USER MAPPING statement.

The following example shows how to map a federated authorization ID to an ODBC data source user ID and password:
CREATE USER MAPPING FOR DB2INST1 SERVER mysql_server
       OPTIONS (REMOTE_AUTHID 'art', REMOTE_PASSWORD 'red4blue')
DB2INST1
You can use any valid local Db2 user ID such as a database instance owner or other users to map the authorization ID for the federated database that is specified in the REMOTE_AUTHID user option.
mysql_server
Specifies the server definition name that you defined in the CREATE SERVER statement for the ODBC data source.
'art'
Specifies the remote user ID to which you are mapping arturo. The value is case-sensitive, unless you set the FOLD_ID server option to 'U' or 'L' in the CREATE SERVER statement.
'red4blue'
Specifies the remote password that is associated with 'art'. The value is case-sensitive, unless you set the FOLD_PW server option to 'U' or 'L' in the CREATE SERVER statement.

Db2 special register USER

You can use the Db2 special register USER to map the authorization ID of the person who is issuing the CREATE USER MAPPING statement to the data source authorization ID that is specified in the REMOTE_AUTHID user option.

The following example shows a CREATE USER MAPPING statement that includes the special register USER:
CREATE USER MAPPING FOR USER SERVER mysql_server
       OPTIONS (REMOTE_AUTHID 'art', REMOTE_PASSWORD 'red4blue');