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 PGCES-02 Exam - Topic 4 Question 95 Discussion

Select the correct result generated by execution of the following SQL statements:CREATE TABLE log (id int, message TEXT, logtime TIMESTAMP); CREATETABLE log_01 () INHERITS (log);INSERT INTO log_01 VALUES (1, 'error', CURRENT_TIMESTAMP);SELECT * FROM log;
E) 'SELECT' statement returns 1 row, and exits successfully.
D) 'SELECT' statement returns 0 rows, and exits successfully.
B) Second 'CREATE TABLE' generates a syntax error.
A) First 'CREATE TABLE' generates a syntax error.
C) 'INSERT' statement generates an error stating that the number of columns and values do not match'.

PostgreSQL PGCES-02 Exam - Topic 4 Question 95 Discussion

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

Select the correct result generated by execution of the following SQL statements:

CREATE TABLE log (id int, message TEXT, logtime TIMESTAMP); CREATE

TABLE log_01 () INHERITS (log);

INSERT INTO log_01 VALUES (1, 'error', CURRENT_TIMESTAMP);

SELECT * FROM log;

Show Suggested Answer Hide Answer
Suggested Answer: E

Contribute your Thoughts:

0/2000 characters
Amos
10 hours ago
Still, SELECT * from log shows no rows.
upvoted 0 times
...
Bette
6 days ago
But it inherits from log, right?
upvoted 0 times
...
Theron
11 days ago
Agreed, log_01 is empty.
upvoted 0 times
...
Lashawna
16 days ago
I think it will show nothing.
upvoted 0 times
...
Carman
2 months ago
It should show the inserted row in log_01, right?
upvoted 0 times
...
Hortencia
2 months ago
I thought you couldn't select from the parent table like that?
upvoted 0 times
...
Deandrea
2 months ago
Wait, does log_01 actually have the data from log?
upvoted 0 times
...
Nakisha
3 months ago
Totally agree, the inheritance is key here!
upvoted 0 times
...
Jonell
3 months ago
The log table is created first.
upvoted 0 times
...
Elenora
3 months ago
Wait, is this a trick question? I'm so confused, but I'm going to go with the empty result set too. Gotta play it safe, you know?
upvoted 0 times
...
Keith
3 months ago
Haha, this question is like a game of SQL Jeopardy! I'm going to go with the empty result set just to be safe.
upvoted 0 times
...
Vilma
3 months ago
I think the question is trying to trick us. The data should be in the log table since it's being inserted into the child table log_01.
upvoted 0 times
...
Ailene
3 months ago
Hmm, I'm not sure about that. Shouldn't the data be visible in the parent table log as well?
upvoted 0 times
...
Frederica
4 months ago
The correct result is an empty result set, as the data is inserted into the child table log_01 and not the parent table log.
upvoted 0 times
...
Johana
4 months ago
I believe the log table won't show the inserted row since it only exists in log_01. I hope I remember this correctly!
upvoted 0 times
...
Aileen
4 months ago
This reminds me of a practice question where we had to deal with table inheritance. I feel like the output will be empty too, but I can't recall the exact details.
upvoted 0 times
...
Lenita
5 months ago
I'm not entirely sure, but I remember something about inheritance in SQL. The data might not show up in the parent table since the insert was done in the child table.
upvoted 0 times
...
Chanel
5 months ago
I think the SELECT statement will return an empty result because we are selecting from the parent table, and we haven't inserted anything into it.
upvoted 0 times
...
Casey
5 months ago
Alright, let me walk through this step-by-step. We create the 'log' table, then create 'log_01' as a child table that inherits from 'log'. When we insert into 'log_01', that data gets propagated up to the parent 'log' table. So the SELECT should return the row we inserted. I think I've got the right approach here.
upvoted 0 times
...
Davida
5 months ago
I think I've got this. Since 'log_01' inherits from 'log', any rows inserted into 'log_01' will also be visible in the 'log' table. So the SELECT * FROM log; should return the row we inserted into 'log_01'. Feeling pretty confident about this one.
upvoted 0 times
...
Hester
5 months ago
I'm a bit confused on the table inheritance part. Does that mean the data in 'log_01' will automatically show up in the 'log' table? I'll need to review how that works before answering this.
upvoted 0 times
...
Evangelina
6 months ago
Okay, let's see here. We're creating a table 'log' and then creating a child table 'log_01' that inherits from it. Then we insert a row into 'log_01'. The question is asking what the SELECT * FROM log; will return. Interesting, let me work this through.
upvoted 0 times
...
Marcos
6 months ago
Hmm, this looks like a question on inheritance and polymorphism in SQL. I'll need to think through how the table inheritance works and how the data gets propagated.
upvoted 0 times
...

Save Cancel