CREATE USER MAPPING statement - Examples for the Microsoft SQL Server wrapper
Use the CREATE USER MAPPING statement to map a federated authorization ID to a remote Microsoft SQL Server 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 a Microsoft
SQL Server remote server user ID and password:
CREATE USER MAPPING FOR DB2INST1 SERVER sqlserver
OPTIONS (REMOTE_AUTHID 'liz', REMOTE_PASSWORD 'abc123')- 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.
- SERVER sqlserver
- Specifies the server definition name that you registered in the CREATE SERVER statement for the Microsoft SQL Server remote server.
- REMOTE_AUTHID 'liz'
- Specifies the remote user ID to which you are mapping elizabeth. The value is case-sensitive, unless you set the FOLD_ID server option to 'U' or 'L' in the CREATE SERVER statement.
- REMOTE_PASSWORD 'abc123'
- Specifies the remote password that is associated with 'liz'. 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 remote user ID that is specified in the REMOTE_AUTHID option.
The following example shows a CREATE USER MAPPING
statement that includes the special register USER:
CREATE USER MAPPING FOR USER SERVER sqlserver
OPTIONS (REMOTE_AUTHID 'liz', REMOTE_PASSWORD 'abc123');