Tables, Keys & Constraints · Question 12 · Medium

Tables, Keys & Constraints question 12

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

The table Emp below exists when these statements run. What does the final SELECT return?

CREATE VIEW HighPaid AS
  SELECT name FROM Emp WHERE salary > 50000;
INSERT INTO Emp VALUES (4, 'Dev', 72000);
SELECT COUNT(*) FROM HighPaid;
  1. 2
  2. 3
  3. 1
  4. 4
Answer and explanation

Answer: B. 3

Explanation: A view stores only its query, not a copy of the data. Each time the view is read the query runs again on Emp, so it now finds Bala, Chirag and the newly inserted Dev, all above 50000.

Previous: Table Team has rows (1, Mumbai) and (2, Chennai). Table Player has rows… · Next: Table Emp: id | name | salary 1 | Asha | 42000 2 | Bala | 65000 3 | Chirag |…

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