Show Columns — SQL Technical Interview Questions & Answers
Show Columns
Show Columns
- SHOW COLUMNS FROM students; is DESCRIBE in another spelling. SHOW COLUMNS FROM students LIKE 'm%'; filters. information_schema.COLUMNS is the joinable catalog.
- Trap: memorising both SHOW COLUMNS and DESC as ‘different concepts’. They answer the same question.
- On the example next to this theory: Show Columns: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.
Technical Interview Tip: SHOW COLUMNS FROM students; = DESCRIBE students;
Code Examples for Show Columns
Show Columns — sample query
-- Show Columns
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 Columns: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.
How to Explain Show Columns to an Interviewer
SHOW COLUMNS vs DESCRIBE?
Same idea Column names, types, keys