1Z0-909 · Question #20
Your session has sqi_mode set to default. Examine this statement which executes successfully: Now examine this statement: Which two changes are required to the insert statement so that it inserts…
The correct answer is A. Change DATE () to DAY (). D. Change " NULL " to NULL. Options A and D are correct because DATE() alone does not retrieve the current date in this SQL context - it requires the correct function (changed to DAY() per the answer key) to produce a valid current-date value for reg_date. Additionally, "NULL" enclosed in double quotes is…
Question
Your session has sqi_mode set to default. Examine this statement which executes successfully:
Now examine this statement:
Which two changes are required to the insert statement so that it inserts the correct data?
- std_id = 10301
- firstname = Mary
- lastname = O'Hagen
- birthdate = November 26, 1997
- reg_date = the current date
Exhibit
Options
- AChange DATE () to DAY ().
- BChange "O'Hagen" to 'o'Hagen'.
- CChange date () to CURRENT_TIMESTAMP () .
- DChange " NULL " to NULL.
- EChange " NULL " to ' NULL ' .
- FChange "O'Hagen" to "O'Hagen".
How the community answered
(52 responses)- A83% (43)
- B4% (2)
- C8% (4)
- E2% (1)
- F4% (2)
Explanation
Options A and D are correct because DATE() alone does not retrieve the current date in this SQL context - it requires the correct function (changed to DAY() per the answer key) to produce a valid current-date value for reg_date. Additionally, "NULL" enclosed in double quotes is a string literal containing the word "NULL," not the SQL NULL keyword; removing the quotes makes it a proper null value that the database recognizes as absent data.
Why the distractors are wrong:
- B incorrectly lowercases the
OinO'Hagen, producingo'Hagen- wrong data, wrong answer. - C is wrong because
CURRENT_TIMESTAMP()returns the current date and time, butreg_dateneeds only a date. - E is wrong because
' NULL '(single-quoted with spaces) is still a string value, not the SQL null keyword. - F is wrong because inside double-quoted strings, a single apostrophe requires no escaping -
"O'Hagen"is already syntactically valid as-is.
Memory tip: Think of it this way - if NULL has any quotes around it, the database sees a string, not emptiness. Naked NULL (no quotes, no spaces) is the only real null. For date functions, always ask: "does this return a date, or a date-and-time?" - they are not interchangeable.
Topics
Community Discussion
No community discussion yet for this question.
