What are GRANT and REVOKE?
Common Permissions
| Permission | What User Can Do | Example |
|---|---|---|
| SELECT | Read data | View customer list |
| INSERT | Add new data | Create new order |
| UPDATE | Modify data | Change price |
| DELETE | Remove data | Delete old records |
| ALL | Everything | Full control |
5 rows
GRANT gives permissions to users. REVOKE takes away permissions.
Simple analogy: Like giving someone the key to your house (GRANT) or taking it back (REVOKE).
GRANT - Give Permission
Common Permissions
| Permission | What User Can Do | Example |
|---|---|---|
| SELECT | Read data | View customer list |
| INSERT | Add new data | Create new order |
| UPDATE | Modify data | Change price |
| DELETE | Remove data | Delete old records |
| ALL | Everything | Full control |
5 rows
Example 1: Allow Someone to Read Data
GRANT SELECT ON students TO john;Now user "john" can read the students table.
Example 2: Allow Insert and Update
GRANT INSERT, UPDATE ON products TO mary;User "mary" can add and modify products.
Example 3: Give All Permissions
GRANT ALL ON orders TO admin_user;Admin can do everything with orders table.
REVOKE - Remove Permission
Common Permissions
| Permission | What User Can Do | Example |
|---|---|---|
| SELECT | Read data | View customer list |
| INSERT | Add new data | Create new order |
| UPDATE | Modify data | Change price |
| DELETE | Remove data | Delete old records |
| ALL | Everything | Full control |
5 rows
Example 1: Remove Read Permission
REVOKE SELECT ON students FROM john;User "john" can no longer read students table.
Example 2: Remove All Permissions
REVOKE ALL ON products FROM mary;User "mary" loses all access to products.
Common Permissions
Common Permissions
| Permission | What User Can Do | Example |
|---|---|---|
| SELECT | Read data | View customer list |
| INSERT | Add new data | Create new order |
| UPDATE | Modify data | Change price |
| DELETE | Remove data | Delete old records |
| ALL | Everything | Full control |
5 rows
SELECT: Can read data INSERT: Can add new data UPDATE: Can modify data DELETE: Can remove data ALL: Can do everything
Real Example
Common Permissions
| Permission | What User Can Do | Example |
|---|---|---|
| SELECT | Read data | View customer list |
| INSERT | Add new data | Create new order |
| UPDATE | Modify data | Change price |
| DELETE | Remove data | Delete old records |
| ALL | Everything | Full control |
5 rows
-- Give sales team read-only access
GRANT SELECT ON customers TO sales_team;
GRANT SELECT ON orders TO sales_team;
-- Give manager full access
GRANT ALL ON customers TO manager;
GRANT ALL ON orders TO manager;Summary
Common Permissions
| Permission | What User Can Do | Example |
|---|---|---|
| SELECT | Read data | View customer list |
| INSERT | Add new data | Create new order |
| UPDATE | Modify data | Change price |
| DELETE | Remove data | Delete old records |
| ALL | Everything | Full control |
5 rows
GRANT = Give permissions REVOKE = Take away permissions Controls who can read/write data