This Oracle tutorial explains how to use the Oracle CREATE USER statement with syntax and examples.
The CREATE USER statement creates a database account that allows you to log into the Oracle database.
The syntax for the CREATE USER statement in Oracle/PLSQL is:
The name of the database account that you wish to create.
Optional. It is the name of the profile that you wish to assign to the user account to limit the amount of database resources assigned to the user account. If you omit this option, the DEFAULT profile is assigned to the user.
Optional. If this option is set, then the password must be reset before the user can log into the Oracle database.
Optional. It disables access to the user account.
Optional. It enables access to the user account.
If you wanted to execute a simple CREATE USER statement that creates a new user and assigns a password, you could do the following:
For example:
This CREATE USER statement would create a new user called smithj in the Oracle database whose password is pwd4smithj, the default tablespace would be tbs_perm_01 with a quota of 20MB, and the temporary tablespace would be tbs_temp_01.
If you wanted to make sure that the user changed their password before logging into the database, you could add the PASSWORD EXPIRE option as follows:
To create an External Database user, you could execute the following CREATE USER statement:
This CREATE USER statement would create an External Database user called external_user1 that has a default tablespace of tbs_perm_01 with a quote of 5MB, and is limited by the database resources assigned to external_user_profile.
To create an External Database user that is only accessible by an operating system account, you could run the following CREATE USER statement:
Note that the only difference between this CREATE USER statement and the previous is the ops$ in front of the user_name.
To create a Global Database user, you could execute the following CREATE USER statement:
This CREATE USER statement would create a Global Database user called global_user1 that has a default tablespace of tbs_perm_01 with a quote of 10M.