Creates a special security profile entry to identify a database user. That user can be granted roles, which in turn provide access to database objects.
1 – Environment
You can use the CREATE USER statement: o In interactive SQL o Embedded in host language programs o As part of a procedure in an SQL module or other compound statement o In dynamic SQL as a statement to be dynamically executed
2 – Format
CREATE USER --+---> <username> ----> IDENTIFIED EXTERNALLY --+-----+ +---> PUBLIC ----------------------------------+ | +------------------------------------------------------------------+ +-------------+-------------------------------+--------------------> +---> create-user-opts ---------+ create-user-opts = -+-> ACCOUNT --+->LOCK ---+---------------------+--> | +->UNLOCK -+ | +-> COMMENT IS -+-> '<string>' --+-------------+ | +------- / <-----+ | +-> NO PROFILE -------------------------------+ +-> PROFILE <profile_name> --------------------+
3 – Arguments
3.1 – ACCOUNT lock-option
Syntax options: ACCOUNT LOCK | ACCOUNT UNLOCK The ACCOUNT LOCK clause disables access to the database by the user for whom the CREATE USER statement is being applied. The ACCOUNT UNLOCK clause allows that user access to the database. The ACCOUNT UNLOCK clause is the default.
3.2 – COMMENT IS 'string'
Adds a comment about the user. SQL displays the text of the comment when it executes a SHOW USERS statement. Enclose the comment in single quotation marks (') and separate multiple lines in a comment with a slash mark (/).
3.3 – IDENTIFIED_EXTERNALLY
Indicates that the user will be authenticated through the operating system.
3.4 – PROFILE
Syntax options: PROFILE | NOPROFILE Identifies a new profile for assignment to the user. The specified profile name must be the name of an existing profile. NOPROFILE is the default behavior and indicates that no special restrictions are applied to this user.
3.5 – PUBLIC
Explicitly creates a PUBLIC security profile entry in the database.
3.6 – username
The name of the user to add to the database. This must match the name of an existing OpenVMS username.
4 – Examples
Example 1: Creating a New User and Locking Her Account SQL> CREATE USER munroy IDENTIFIED EXTERNALLY cont> ACCOUNT LOCK cont> COMMENT IS 'User munroy starts job on'/ cont> 'May 1, 2003. Unlock when she starts'; Example 2: Adding a profile to a user This example creates a new profile that defines the DEFAULT transaction and then assigns a profile while creating a new user. The next time the user attaches to the database the START DEFAULT TRANSACTION statement will use the defined profile instead of the standard READ ONLY default. SQL> create profile READ_COMMITTED cont> default transaction read write isolation level read committed wait 30; SQL> show profile READ_COMMITTED READ_COMMITTED Default transaction read write wait 30 Isolation level read committed SQL> create user JAIN identified externally profile READ_COMMITTED; SQL> show user JAIN; JAIN Identified externally Account is unlocked Profile: READ_COMMITTED No roles have been granted to this user