PGoCareerGoCareer prep tools
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

SQL · Theory

Grant Privilege

← All stacks

Theory

75/439

Grant Privilege

GRANT SELECT, INSERT ON college.* TO 'asha'@'localhost'; lets asha read and insert in that database. FLUSH PRIVILEGES is needed only for some older grant-table edits — GRANT statement usually applies at once.

Least privilege — the app user does not get DROP or GRANT OPTION. Host 'localhost' vs '%' matters.

Trap — GRANT ALL ON *.* TO an app. Trap: forgetting the quotes around 'user'@'host'.

On the example next to this theory: Grant Privilege: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

Exam tip

GRANT SELECT, INSERT ON college.* TO 'asha'@'localhost';

Grant Privilege — sample query

-- Grant Privilege
CREATE TABLE demo (
  id INTEGER PRIMARY KEY,
  label TEXT NOT NULL,
  qty INTEGER DEFAULT 0
);
INSERT INTO demo (id, label, qty) VALUES
  (1, 'alpha', 2),
  (2, 'beta', 5);
SELECT label, qty FROM demo WHERE qty >= 2 ORDER BY qty DESC;

Grant Privilege: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

Short notes

  • DefGRANT gives a user rights on a DB/table.
  • RuleLeast privilege. 'user'@'host'.
  • TrapGRANT ALL ON *.* for an app user.

Questions

1

Give a student user read-only?

75 / 439

P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.