Describe Table — SQL Technical Interview Questions & Answers
Describe Table
Describe Table
- DESCRIBE students; or DESC students; prints columns, types, NULL, key, default. Same idea: SHOW COLUMNS FROM students; or SHOW CREATE TABLE students; (full CREATE text including keys).
- Use this when you forgot whether marks is INT or VARCHAR. Don’t guess types in an interview — DESCRIBE.
- Trap: DESCRIBE on a view still works, but you won’t see indexes the same way as a base table.
- On the example next to this theory: Describe Table: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.
Technical Interview Tip: DESC students; and SHOW CREATE TABLE students;
Code Examples for Describe Table
Describe Table — sample query
-- Describe Table
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;Describe Table: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.
How to Explain Describe Table to an Interviewer
How do you see column types?
DESCRIBE students; SHOW CREATE TABLE students;