QuestionQ14

Data Storage and Processing

An Architect runs the following statements in sequence:

create table emp(id integer);  
insert into emp values (1),(2);  
create temporary table emp(id integer);  
insert into emp values (1);  

The Architect then runs these statements:

select count(*) from emp;  
drop table emp;  
select count(*) from emp;  

What is the result?

Explanation

A temporary table with the same name as a permanent table takes precedence for unqualified references in its session. The first count therefore returns 1. DROP TABLE emp drops the temporary table, after which the permanent table is again visible and its count returns 2.

Community Discussion

No comments yet. Be the first to start the discussion!