How to use CREATE USER Statement In SQL
The CREATE USER
statement is a fundamental command for database administrators allowing them to create new users and grant them specific privileges within the database. It requires specifying the username and password for the new user.
Syntax for Create a New User:
CREATE USER username IDENTIFIED BY password;
Here we can substitute “username” for the desired name, whereas “password” stands for a secure access key.
Example: Let’s say we wanted to create a user called “Anya” with the password “pass123.”
CREATE USER anya IDENTIFIED BY pass123;
Output:
Explanation: Our User has been created.
Let’s Granting Privileges to the Anya
In PL/SQL, GRANT statement plays an important role in giving away administrative or DBA rights. Depending upon specific needs, GRANT statement is used for different allocation of privileges. This command grants all database administration rights across entire databases upon this specific user by dint of his DBA role.
Syntax for Grant Privileges:
GRANT DBA TO username;
Example: For instance, anya receives full database administration privileges through the DBA role.
GRANT DBA TO anya;
Output:
Explanation: As we can see in the above image that privileges grant to the Anya. See in the below image to get visual representation of grant privileges Anya
How to Create a User With Full Privileges in PL/SQL?
In database administration, the ability to manage user privileges is very important. As a database administrator, we may find ourselves in the position of creating users with full privileges and granting them the authority to manage and manipulate the database.
In this article, we will learn about CREATE USERS and give them GRANT or Privileges to access information using various methods and examples too.