Table of contents
Connection to SQL Plus
In reality, we have two ways to utilize SQL Plus tool.
-
Using Termial on Linux or CMD on Windows
-
Typing cmd on Window + R dialog
-
After that, running command.
sqlplus / as sysdba
-
-
Open directly SQL Plus
-
On Window taskbar, typing the SQL plus and enter it.
-
Then, we have SQL plus’s UI like the below image.
-
Enter username as sys as sysdba, and password that we type when setting up Oracle database.
-
Create user account
According to Oracle’s website, we have the flow for creating user.
Then, we will run the below command.
CREATE USER weblogic123 IDENTIFIED BY weblogic123;
Sometimes, we will encounter a problem like:
The reason why Oracle causes this error is that it need the prefix c## of username.
In order to solve this error, we have two solutions:
-
Using prefix c## with username
CREATE USER c##weblogic123 IDENTIFIED BY weblogic123;
-
Setting the “_ORACLE_SCRIPT”=true
ALTER SESSION SET "_ORACLE_SCRIPT"=true;
Then, we will continue creating our new user.
CREATE USER weblogic123 IDENTIFIED BY weblogic123;
The drawback of this solution:
- Using hidden parameter _ORACLE_SCRIPT is dangerous in a production system and might also invalidate our support contract.
Grant roles
Belows are some roles that we need to assign for users.
- CONNECT role
- RESOURCE role allows a user to create named types for custom schemas.
- DBA role allows the user to not only create custom named types, but alter and destroy them as well.
GRANT CONNECT, RESOURCE, DBA TO weblogic123;
Grant privileges
-
Grant a privilege to connect to oracle database
GRANT CREATE SESSION TO weblogic123; GRANT CREATE SESSION GRANT ANY PRIVILEGE TO weblogic123;
-
Grant a privilege that a user can have a disk space to modify or create tables or data.
GRANT UNLIMITED TABLESPACE TO weblogic123;
-
Grant a privilege for operations with table
To know more about the table privileges, we can refer https://docs.oracle.com/database/121/DBSEG/authorization.htm#DBSEG99919.
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE ON database_name TO username;
-
Grant all privileges
GRANT ALL PRIVILEGES TO weblogic123;
Wrapping up
- Understanding about how to create user account and grant privilege for users in Oracle database.
Refer:
https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_8003.htm
https://www.oracletutorial.com/oracle-administration/oracle-grant-all-privileges-to-a-user/
https://docs.oracle.com/cd/A97630_01/server.920/a96524/c24privs.htm