Back to SQL Course - Back to Command Types
It’s used for access the stored data.
Commands are GRANT and REVOKE.
It’s used to provide access or privileges on the database objects to the users.
GRANT <privilegeName>
ON <objectName>
TO {<userName> | <roleName>};
It’s used to revoke access or privileges on the database objects to the users.
REVOKE <privilegeName>
ON <objectName>
FROM {<userName> | <roleName>};
Privilege | Description |
---|---|
SELECT | select statement on the table |
INSERT | insert statement on the table |
UPDATE | update statement on the table |
DELETE | delete statement on the table |
INDEX | create an index on the table |
CREATE | create table statement |
ALTER | alter table statement |
DROP | drop table statement |
ALL | grant all privileges except for GRANT |
GRANT | allow to grant / manage privileges |
-- single privilege to a single user with db
GRANT SELECT
ON employee
TO manuel@localhost;
-- multiple privileges to a single user
GRANT SELECT, INSERT, UPDATE, DELETE
ON employee
TO manuel;
-- all privileges to a single role with db
GRANT ALL
ON employee
TO dev@localhost;
-- single privilege to a single user with db
REVOKE SELECT
ON employee
FROM manuel@localhost;
-- multiple privileges to a single user
REVOKE SELECT, INSERT, UPDATE, DELETE
ON employee
FROM manuel;
-- all privileges to a single role with db
REVOKE ALL
ON employee
FROM dev@localhost;
Back to SQL Course - Back to Command Types
Let’s connect
If you want to learn more about the topic, connect or send me a DM.