Tables, Keys & Constraints · Question 13 · Medium

Tables, Keys & Constraints question 13

Table Emp:
id | name | salary
1 | Asha | 42000
2 | Bala | 65000
3 | Chirag | 58000

The table Emp below has 3 rows when these statements run. What happens when the SELECT runs?

DROP TABLE Emp;
SELECT COUNT(*) FROM Emp;
  1. It returns 0
  2. It fails, because the table Emp no longer exists
  3. It returns 3
  4. It returns NULL
Answer and explanation

Answer: B. It fails, because the table Emp no longer exists

Explanation: DROP TABLE removes the rows and the table definition itself, so there is nothing left to query and the SELECT is an error. A count of 0 is what DELETE without WHERE or TRUNCATE would leave, because they keep the empty table.

Previous: Table Emp: id | name | salary 1 | Asha | 42000 2 | Bala | 65000 3 | Chirag |… · Next: The primary key below is made of two columns. What does the final SELECT return?

Practise tables, keys & constraints

Try a fresh set of tables, keys & constraints questions with an explanation after every answer, free and without signing up: Tables, Keys & Constraints practice. Or sit a full placement mock test.

More tables, keys & constraints questions

More sql practice

DML & Transactions · SELECT, WHERE & ORDER BY · SQL Joins · Aggregates & GROUP BY · Subqueries & CTEs · Window Functions · NULL Handling · SQL Functions & CASE

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge