Site icon IT Tutorial

Oracle SQL Tutorial -9 Managing User Access

Hi ,

in this article , I will tell you about user creation and user access .

USER ACCESS

Each user is logged into the system with their user name and password . After this permission , all the actions of the users are subject to authorization control .

SYSTEM AUTHORITIES

Most of the system privileges are used by DBAs . To give an example of these powers :

CREATE USERS

DBAs perform user creation . The user name and password are given when creating the user , and everything else is given by default .

CREATE USER user 
IDENTIFIED BY password;
CREATE USER MELIKE
IDENTIFIED BY "Sifre124";

SYSTEM AUTHORITIES FOR USERS

The first user is created , then the DBAs give the desired system privileges to the users . Since the authorizations given are important , care must be taken when authorizing them .

GRANT PRIVILEGE[ , privilege..]
TO user [ ,user | role, PUBLIC..];
GRANT CREATE TABLE TO MELIKE;

System privileges for a developer :

CREATE USER MDRN IDENTIFIED BY Medu_0123456;

GRANT CONNECT,RESOURCE TO MDRN;

Now let’s write our query into the table :

SELECT * FROM ADMIN.NEW_TABLO;

We got an error because we don’t have authority .

ROLE

ROLE BUILDING AND AUTHORIZATION

CREATE ROLE DEVELOPER_ROLE;

Our role is now ready to authorize :

GRANT SELECT ANY TABLE TO DEVELOPER_ROLE;
GRANT UPDATE ANY TABLE,INSERT ANY TABLE TO DEVELOPER_ROLE;

GRANT DEVELOPER_ROLE TO MDRN;

OBJECTIVES

The owner of the object has all the authority over the object , and at the same time , the object owner can authorize others for that object .

To give an example of how to use :

GRANT object_priv [(columns)] 
ON object 
TO {user | role | PUBLIC}
[ WITH GRANT OPTION] ;
GRANT DELETE ON ADMIN.NEW_TABLE TO MDRN;
GRANT INSERT,UPDATE ON ADMIN.NEW_TABLE TO MDRN;
GRANT CREATE ANY SEQUENCE TO MDRN;
GRANT CREATE TABLE TO MDRN;

WITH GRANT OPTION

GRANT DELETE ON ADMIN.NEW_TABLE TO MDRN WITH GRANT OPTION;
GRANT INSERT,UPDATE ON ADMIN.NEW_TABLE TO MDRN WITH GRANT OPTION;

AUTHORIZATION

We revoke the authority given to the user or role with the REVOKE command .

REVOKE {privilege [ , privilege ...] | ALL }
ON object
FROM {user [ , user ...] | role | PUBLIC }
[CASCADE CONTRAINTS];

Let us revoke the privileges we have already granted to MDRN :

REVOKE DELETE ON ADMIN.NEW_TABLE FROM MDRN;

See you in my next post.

Exit mobile version