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:
- Log in to the Oracle database using the system administrator account (such as sys or system).
- Create a new user (for example, new_user) and set a password using the following statement:
CREATE USER new_user IDENTIFIED BY password;
- Grant permission to new users to connect to the database.
GRANT CREATE SESSION TO new_user;
- Grant new users additional permissions based on specific needs, such as:
- Grant SELECT permission on a specific table to new users.
GRANT SELECT ON table_name TO new_user;
- Grant new users INSERT permissions on a specific table.
GRANT INSERT ON table_name TO new_user;
- Grant new users UPDATE permissions on a specific table.
GRANT UPDATE ON table_name TO new_user;
- Grant new users DELETE permission on a specific table.
GRANT DELETE ON table_name TO new_user;
- 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.