Which of the following will display a list of tables in a database ?
2023
Which of the following will display a list of tables in a database ?
- A.
DISPLAY TABLES; / DISPLAY TABLES;
- B.
SHOW TABLES; / SHOW TABLES;
- C.
SELECT TABLES; / SELECT TABLES;
- D.
VIEW TABLES; / VIEW TABLES;
Attempted by 2394 students.
Show answer & explanation
Correct answer: B
Answer: SHOW TABLES;
Explanation: The command SHOW TABLES; lists all tables in the currently selected database in MySQL and MariaDB.
Usage: Run SHOW TABLES; after selecting the desired database with USE database_name;.
Portable alternative: SELECT table_name FROM information_schema.tables WHERE table_schema = 'your_database_name'; This works in many SQL systems that support the information_schema.
Why other commands are incorrect: DISPLAY TABLES;, SELECT TABLES;, and VIEW TABLES; are not standard SQL commands for listing tables.
A video solution is available for this question — log in and enroll to watch it.