Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

PostgreSQL Exam PGCES-02 Topic 1 Question 37 Discussion

Actual exam question for PostgreSQL's PGCES-02 exam
Question #: 37
Topic #: 1
[All PGCES-02 Questions]

The table "custom" is defined below. The "id" column and "introducer" column are of

INTEGER type, and the "email" column is of TEXT type.

id | email | introducer ----+-- ---------------+-----------2 |

aaa@example.com | 1 3 |

bbb@example.com | 2 4 |

ccc@example.com | 2

Three SQL statements were executed in the following order:

UPDATE custom SET email = '' FROM custom c WHERE

custom.introducer = c.id; UPDATE custom SET introducer = NULL

WHERE introducer NOT IN (SELECT id FROM custom); DELETE

FROM custom WHERE id = 2 OR introducer = 2; Select the number of rows in the "custom" table after the execution.

Show Suggested Answer Hide Answer
Suggested Answer: A

Contribute your Thoughts:

Leota
1 months ago
Ah, the good old 'UPDATE, UPDATE, DELETE' dance. It's like a SQL ballet, with a tragic ending for row 2. I hope the other rows make it out alive!
upvoted 0 times
Jaclyn
8 days ago
I'm pretty sure there will be 0 rows left in the table.
upvoted 0 times
...
Celeste
20 days ago
I believe only 1 row will remain in the table.
upvoted 0 times
...
Twana
21 days ago
I think after the execution, there will be 2 rows left in the table.
upvoted 0 times
...
...
Chery
1 months ago
Hmm, this is a tricky one. I'm going to go with E) 4 rows. The SQL statements don't seem to delete any rows, they just update the data. So the final table should still have the original 4 rows.
upvoted 0 times
Anna
19 days ago
I'm going with C) 2 rows. The DELETE statement removes 2 rows, leaving 2 rows in the table.
upvoted 0 times
...
Ayesha
20 days ago
I believe it's B) 1 row. The UPDATE statements change the data, but the DELETE statement only removes 1 row.
upvoted 0 times
...
Lynette
21 days ago
I think it's A) 0 rows. The DELETE statement removes rows where id = 2 or introducer = 2, which would remove 2 rows.
upvoted 0 times
...
...
Robt
2 months ago
D) 3 rows seems like the right answer to me. The first two statements don't actually delete any rows, they just update the email and introducer columns. The third statement only removes 2 rows, so there should be 3 rows left.
upvoted 0 times
Matthew
18 days ago
I agree with you, C) 2 rows makes sense. The last statement is the only one that actually deletes rows.
upvoted 0 times
...
Stefania
20 days ago
I think the answer is C) 2 rows. The last statement deletes 2 rows, so there should be 2 rows left.
upvoted 0 times
...
...
Carry
2 months ago
I'm going with B) 1 row. The third statement deletes the row with id = 2 and all rows where the introducer is 2, which means there should only be 1 row left in the table.
upvoted 0 times
...
Leah
2 months ago
I think the correct answer is C) 2 rows. The first statement updates the email column to empty for all rows where the introducer matches the id. The second statement sets the introducer to NULL for all rows where the introducer is not in the id column. The third statement deletes the row with id = 2 and all rows where the introducer is 2. This leaves us with 2 rows in the table.
upvoted 0 times
Toshia
20 days ago
Finally, the third statement deletes specific rows, leaving us with 2 rows.
upvoted 0 times
...
Marguerita
24 days ago
Then the second statement sets introducer to NULL for non-matching introducers.
upvoted 0 times
...
Antonio
29 days ago
I agree, the first statement updates the email column to empty for matching introducer.
upvoted 0 times
...
Vernice
1 months ago
I think the correct answer is C) 2 rows.
upvoted 0 times
...
...
Junita
2 months ago
But if you look at the SQL statements carefully, it seems like only 2 rows will remain after the execution.
upvoted 0 times
...
Isreal
2 months ago
I disagree, I believe the answer is D) 3 rows.
upvoted 0 times
...
Junita
2 months ago
I think the answer is C) 2 rows.
upvoted 0 times
...

Save Cancel