1z0-071 Exam QuestionsBrowse all questions from this exam

1z0-071 Exam - Question 217


Examine these statements and results:

How many rows are retrieved by the last query?

Show Answer
Correct Answer: C

The final query retrieves 14 rows. A Global Temporary Table (GTT) has session-specific data, and by default, it deletes rows on commit unless specified otherwise. Here, the initial 'INSERT INTO t_emp SELECT * FROM emp' inserts 14 rows, which are then committed and removed. The second insertion also adds 14 rows, leading the count to be 14 when the final query is executed since these rows belong to the same session and have not been committed yet.

Discussion

4 comments
Sign in to comment
WingLOption: B
Jul 12, 2023

Tested. create table PRODUCTS (PROD_ID NUMBER, PROD_NAME VARCHAR2(50), PROD_CATEGORY VARCHAR2(50), PROD_MIN_PRICE NUMBER, PROD_UNIT_OF_MEASURE VARCHAR2(50)) INSERT into PRODUCTS VALUES(101,'Envoy','Hardware',6000,'Nos.') ; INSERT into PRODUCTS VALUES(102,'Y Box','Electronics',9000,'') ; INSERT into PRODUCTS VALUES(103,'DVD','Software/Other',2000,'Nos.') ; INSERT into PRODUCTS VALUES(104,'Documentation','Software/Other',4000,'') ; select * from PRODUCTS create global temporary table t_pro as select * from PRODUCTS insert into t_pro select * from PRODUCTS commit insert into t_pro select * from PRODUCTS select count(*) from t_pro

lucemqy
Nov 15, 2023

You are seeing 0 probably because you are in APEX and APEX commit each line

Mcromeo
Dec 1, 2023

I tested your script select count(*) from t_pro give 0 row

McromeoOption: C
Dec 1, 2023

C is correct

ArslanAltafOption: C
Jun 2, 2024

If you haven't mentioned on commit preserve / Delete, the default behavior of system is to delete all the rows of GTT. So, once commit is complete, rows are deleted. Again, Insert command will copy all the rows from EMP which is 14 C is correct. Tested as well

jm9999Option: C
Sep 26, 2023

I think the default for GTT is 'on commit delete rows'. So after the commit there would be 0 rows but then after the next insert there would be 14.

jm9999
Sep 26, 2023

The interesting thing on this one: It appears as though 'create global temporary table table_name1 as select * from table_name2' creates an empty table even when table_name2 contains rows.

lucemqy
Nov 15, 2023

When you create a table there's implicit COMMIT and GTT default is delete on commit so the table should be 0 rows