Drop User — SQL Technical Interview Questions & Answers
Drop User
Drop User
- Drop User 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: Drop User: 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 Drop User
Drop User — sample query
-- Drop User
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;Drop User: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.
How to Explain Drop User to an Interviewer
What is 'asha'@'localhost'?
A MySQL account Host is part of the identity