Show Tables — SQL Technical Interview Questions & Answers
Show Tables
Show Tables
- SHOW TABLES; lists tables in the current database. USE college; first. SHOW TABLES LIKE 'stu%'; filters names.
- information_schema.TABLES is the SQL way if you need to join metadata. For a viva, SHOW TABLES is enough.
- Trap: SHOW TABLES in the wrong database — empty list, panic, recreate tables that already exist elsewhere.
- On the example next to this theory: Show Tables: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.
Technical Interview Tip: USE college; SHOW TABLES;
Code Examples for Show Tables
Show Tables — sample query
-- Show Tables
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 Tables: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.
How to Explain Show Tables to an Interviewer
How do you list tables?
USE the database SHOW TABLES;