How do I create a new user and assign permissions in Oracle?

To create a new user and assign appropriate permissions in an Oracle database, you can follow the steps below:

  1. Log in to the Oracle database using the system administrator account (such as sys or system).
  2. Create a new user (for example, new_user) and set a password using the following statement:
CREATE USER new_user IDENTIFIED BY password;
  1. Grant permission to new users to connect to the database.
GRANT CREATE SESSION TO new_user;
  1. Grant new users additional permissions based on specific needs, such as:
  1. Grant SELECT permission on a specific table to new users.
GRANT SELECT ON table_name TO new_user;
  1. Grant new users INSERT permissions on a specific table.
GRANT INSERT ON table_name TO new_user;
  1. Grant new users UPDATE permissions on a specific table.
GRANT UPDATE ON table_name TO new_user;
  1. Grant new users DELETE permission on a specific table.
GRANT DELETE ON table_name TO new_user;
  1. Finally, assign roles to new users using the following statement (if necessary).
GRANT role_name TO new_user;

By following the above steps, you can successfully create a new user in the Oracle database and assign the appropriate permissions.

bannerAds