Correct test answer?

Choose the correct syntax to insert rows into dim_country table

Which ones are correct, i kept on trying but test always shows wrong. Any ideas?

The 3rd one is correct. (I'm not sure about the 5th one, since that is not T-SQL (SQL Server) but some other rdbms.)


thanks for your answer but if I pick only third one and press submit it says incorrect.

The first one already checked looked correct. Add the 3rd one to that. And likely the one after the last one selected.

So, overall: 3rd, 6th and 8th would be my best guess.

nope, sadly

Assuming this is PostGreSQL, then 5 is also a valid option, in addition to 3,6 and 8.

1, 2 and 4 are syntactically incorrect.

Hi again,

This is a PostGreSQL, yet the answer is still not valid.

I don't know what to tell you, except to install a PostGreSQL instance and try them out. Or simply try every answer combination until you get the "correct" answer. I'm not a PostGres expert, other than the ones I mentioned being invalid syntax.

#3 is valid syntax and should work for the example DDL posted, and #6 is also valid, unless there's a problem with the date formats in the VALUES clause.


thanks for trying, I really appreciate it.

Is a SERIAL column actually the same as people think of an IDENTITY column? In other words, while you can't insert into a classic IDENTITY column without jumping through a hoop or two, can you insert into a SERIAL column without jumping through such a hoop?

The example they give at the intersection pages 158/159 in the documentation looks like this and they explain it with the alternative.

CREATE TABLE tablename (
colname SERIAL
-- is equivalent to specifying:
CREATE SEQUENCE tablename_colname_seq AS integer;
CREATE TABLE tablename (
colname integer NOT NULL DEFAULT nextval('tablename_colname_seq')

The alternative is a sequence and there's absolutely NOTHING to prevent you from inserting into a column that has a default of "nextval" for a sequence. Of course, you could have a UNIQUE constraint on the column to prevent you from entering DUPLICATE values but there's nothing to prevent you from entering a value with a DEFAULT of a sequence "nextval".

Since they're saying the two are identical, I'm thinking you can enter values into a column designated as a SERIAL.

I don't have Postgres to try it with, either.

1 Like

soo, which answers do you think should correct?

I think we've given enough advice.

Have you tried any of these examples on a PostGreSQL instance? It's free to install and use. I've already made this suggestion.

We don't have the test in front of us, and I assume you're taking this test in order to get some certification. Actually using the product will teach you more about it that any test will.

1 Like

Heh... you're the one that has to have Postgres loaded. And it looks like the "test" give you instant feedback. Spend a minute and try the bloody code! :wink:

1 Like

I tried it and it seems indeed confusing as certain codes work but then i mark it test shows incorrect...