Show Users — SQL Technical Interview Questions & Answers
Show Users
Show Users
- Show Users is about MySQL accounts, not table rows. Users are 'name'@'host'. CREATE USER, GRANT, ALTER USER … IDENTIFIED BY, DROP USER.
- SHOW GRANTS FOR CURRENT_USER; to see yourself. Don’t use root from the app. Lock/unlock is ACCOUNT LOCK.
- Trap: user@localhost vs user@% as two different accounts.
- On the example next to this theory: Show Users: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.
Technical Interview Tip: 'user'@'host', GRANT, not root from the app.
Code Examples for Show Users
Show Users — sample query
-- Show Users
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;Show Users: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.
How to Explain Show Users to an Interviewer
What is 'asha'@'localhost'?
A MySQL account Host is part of the identity