RebellionRider | RebellionRider | How to Create a new user account in Oracle using Create user statement

How to Create a new user Oracle

By Manish Sharma

Create a new user using Create user statement.

If you have ever worked with oracle database then you must have come across with different types of user accounts such as sys, hr, OE, Scott and many more. These are the user accounts which oracle creates for you. What if you want to create your own user accounts? In this tutorial you will learn how to create a user account in oracle database.

Among several different ways, creating a user account using Create User statement is the most common one. Using “create user” statement you can create and configure new database user and by using this database user you can log on to your database.

Syntax of Create User statement

 CREATE USER username IDENTIFIED BY password/externally/globally
 DEFAULT TABLESPACE tablespace_name TEMPERORY TABLESPACE tablespace_name
 QUOTA size/unlimited ON tablespace_name
 PROFILE profile_name
 PASSWORD expire
 ACCOUNT lock/unlock;

Create and user both are the keywords followed by the username. As username you can give any name of your choice. After that we have IDENTIFIED BY clause which helps the oracle engine in authenticating the user. There are three ways of authenticating a user

  1. Password: Password clause lets you create a local user and indicates that the user must specify password to log on to the database. Remember here: passwords are case sensitive. Passwords can consist of only single-byte characters from your database character set regardless of whether the character set also has multi-byte characters.
  2. Externally: This clause helps you in creating an external user. These external users and their authentication are managed by external services such as operating system. The user who is authenticated by the operating system can easily access the database without being requested for a password. External users are classic regular database users (non-database administrators) who are assigned standard database roles (such as CONNECT and RESOURCE), but no SYSDBA (database administrator) or SYSOPER (database operator) privilege.
  3. Globally: Through Global users you can keep the login or authentication information at a Central Oracle Security Server rather than having passwords in every database to be accessed. Moreover on the assignment of a global user, the authorization information can be assigned globally as well. This means that you can assign global roles to global users in the central Oracle Security Server, instead of assigning the roles in each database.

Default Tablespace: In the default tablespace you have to specify the name of tablespace where this user will create its object. By objects I mean tables, indexes, synonyms etc. This is an optional clause, if you omit this clause then all the objects created by this user gets stored in the database default tablespace which is “users” tablespace in most cases.

Temporary Tablespace: All the temporary segments created by this user get stored here. Temporary segment such as temporary tables; Similar to default tablespace you have to specify the name of the temporary table space here. But make sure the table space you are going to specify here must be temporary tablespace. This is an optional clause so if you omit this clause then all the temporary objects created by this user get stored in the database default temporary tablespace which is “temp” tablespace.
Always remember the name of tablespace you will specify here must be a temporary tablespace and should have a standard block size.Also it should not be an undo tablespace or a tablespace with automatic segment-space management

Quota clause: Quota clause can help you in specifying the maximum amount of space that the user can allocate in the tablespace. In single create user statement you can have multiple quota clause. As you can see here our quota keyword is followed by size. You can either specify a limited size such as 50M or 100M, M stands for Megabyte here or just write UNLIMITED for allocating space without any limits. After the size you have to specify the name of tablespace using ON clause.

Profile clause: Using profile clause you can specify the profile you want to assign to the user. By Assigning profile you can limit the amount of database resources the user can use.
It’s also an optional clause hence if you omit this clause database will assign a default profile to your user.

Password Expire clause: This is the kind of settings which force your user to change the password on the first login attempt or say before the user can log in to the database. This is also an optional clause.

Account clause: Using Account clause you can set the status of your user account. If you set the status on lock then oracle will create your user account but disable its access. This means that you will have your user account but you cannot use it. If you set the status on UNLOCK then you are all free to use it. Unlock means status will be open. By default its set on UNLOCK option.
It’s again optional if you omit this clause. In case you do omit it then the Oracle will set the status of your account to default state on UNLOCK.

Example for Creating A New User Account In Oracle

How to create user account with whole manual settings

Let say you want to create a user by the name of Jarvis with authentication type password and want to allot 20MB space on users tablespace which will be its default tablespace and the temporary tablespace will be temp.


Above query will create a new user account by the name of ironman but you will not be able to log on to your database with this user because a newly created user cannot connect to the database until granted the CREATE SESSION system privilege.
So for that you have to grant the CREATE SESSION system privilege to this user account – ironman.

Here’s how to do this.

Step 1: if on Windows machine just set your oracle SID to your database in which you have created this user

 C:/> set ORACLE_SID=orcl

If on Linux machine then first export your SID and then set it

 $export ORACLE_SID=orcl
 $ set ORACLE_SID=orcl

Step 2:Log on to your database using sys user account with sysdba privileges.

  C:/> sqlplus sys/password as sysdba

Step 3:grant the create session privilege

 SQL>grant connect session to ironman;

That’s all you have to do, your account is now created and ready to get connect to your database.

How to create user account with whole default settings

You can create a new user account with all oracle default settings by using just a small very simple query.

That’s all, just execute the above query and oracle will create you a new user account with all the default settings.

Hope you enjoyed reading please share my videos and blog with your friends. Thanks & Have a great day!

SQL Script and Presentation used

You can DOWNLOAD SQL script and presentation used in the Video and in this article.

SQL Script used in Video and in this article

Do Not Drink & Drive Use My Uber Code "UberRebellionRider"
SignUp using my referral code and get first ride worth $20 FREE

  • Manish Sharma Oracle Rebellion Rider
  • Manish Sharma Oracle certified SQL expert
  • Manish Sharma oracle certified associate
  • Manish Sharma oracle certified professional
  • View Manish Sharma's profile on LinkedIn
  •          View Manish Sharma's profile on LinkedIn