The CREATE USER MAPPING statement defines a mapping between an authorization ID that uses a federated database and the authorization ID and password to use at a specified data source.
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. However, if the bind option DYNAMICRULES BIND applies, the statement cannot be dynamically prepared (SQLSTATE 42509).
Authorization
If the authorization ID of the statement is different than the authorization name that is being mapped to the data source, then the authorization ID must include SYSADM or DBADM authority. Otherwise, if the authorization ID and the authorization name match, then no privileges or authorities are required.
Syntax
>>-CREATE USER MAPPING FOR----+-authorization-name-+------------> '-USER---------------' >-----SERVER--server-name---------------------------------------> .-,-----------------------------------------------. V .-ADD--. | >-----OPTIONS--(-----+------+---user-option-name--string-constant---+---)-> >--------------------------------------------------------------><
Description
Notes
Examples
Example 1: To access a data source called S1, you need to map your authorization name and password for your local database to your user ID and password for S1. Your authorization name is RSPALTEN, and the user ID and password that you use for S1 are SYSTEM and MANAGER, respectively.
CREATE USER MAPPING FOR RSPALTEN SERVER S1 OPTIONS ( REMOTE_AUTHID 'SYSTEM', REMOTE_PASSWORD 'MANAGER' )
Example 2: Marc already has access to a DB2 data source. He now needs access to an Oracle data source, so that he can create joins between certain DB2 and Oracle tables. He acquires a username and password for the Oracle data source; the username is the same as his authorization ID for the federated database, but his Oracle and federated database passwords are different. To be able to access Oracle from the federated database, he must map the two passwords together.
CREATE USER MAPPING FOR MARCR SERVER ORACLE1 OPTIONS ( REMOTE_PASSWORD 'NZXCZY' )