Grant is part of Data Control Language (DCL) that allows us to grant privileges to other users.
We have two types of Grant privileges:
- Granting permissions to users.
- Granting privileges on database objects to the users.
To demonstrate DCL lets create users first.
Creating user-
SQL>Create user user1 identified by user1;
--User created
SQL> Create user user2 identified by user2;
--User created
Granting permissions to users:-
For every new user created in the database, we need to explicitly provide connection and resource privileges to the user so that user can connect and create objects in the database.
Syntax:-
Grant connect, resource to ;
Let’s grant the Connect and resource privileges to the users created:-
SQL>Grant Connect, resource to user1;
-- Grant succeeded
SQL>Grant Connect, resource to user2;
-- Grant succeeded
User1 and user2 can now connect and create database objects in the database.
Granting privileges on database objects to the users.
Objects created in the database are always owned by a specific user. If a different user has to access the object then necessary privileges should be given.
Syntax:-
Grant on
No comments:
Post a Comment