MySQL Questions and Answers – Date and Time Data Types

This set of MySQL Database Multiple Choice Questions & Answers (MCQs) focuses on “Date and Time Data Types”.

1. Which of these has special automatic update behavior?
a) DATE
b) TIME
c) TIMESTAMP
d) YEAR
View Answer

Answer: c
Explanation: The date and time types for representing temporal values are ‘DATE’, ‘TIME’, ‘DATETIME’, ‘TIMESTAMP’ and ‘YEAR’. Each temporal type has a range of valid values and a ‘zero’ value.

2. To disallow zero month or day parts in dates, the option used is _____________
a) NO_ZERO_IN_DATE
b) NO_DATE_WITH_ZERO
c) ZERO_IN_DATE
d) DATE_WITH_ZERO
View Answer

Answer: a
Explanation: MySQL permits to store the dates where the day or month and day are zero in a DATE or DATETIME column. This is helpful for applications that need to store birthdates for which the exact date is unknown.

3. The mode that does not remove trailing spaces when CHAR values are retrieved is _____________
a) PAD_CHAR_TO_FULL_LENGTH
b) TO_FULL_LENGTH_CHAR_PAD
c) CHAR_PAD_TO_FULL_LENGTH
d) PAD_CHAR_TO_LENGTH
View Answer

Answer: a
Explanation: When the CHAR values are stored, they are right-padded with spaces to the specified length. When CHAR values are retrieved, trailing spaces are removed unless the SQL mode ‘PAD_CHAR_TO_FULL_LENGTH’ is enabled.
advertisement
advertisement

4. MySQL automatically converts a date or time value to a number if the value is used in a numeric context.
a) True
b) False
View Answer

Answer: a
Explanation: MySQL automatically converts a date or time value into a number if the value is used in a numeric context and vice versa. A ‘zero’ value can also be represented in MySQL.

5. The functions in Perl DBI called?
a) functions
b) procedures
c) methods
d) programs
View Answer

Answer: c
Explanation: In the DBI API, functions are called and pointers to structures are used. The functions are called ‘methods’, pointers are called ‘references’, pointer variables are called ‘handles’.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. The variable used as a handle to an open file is ______________
a) $dbh
b) $sth
c) $fh
d) $h
View Answer

Answer: c
Explanation: The variable named ‘$fh’ is a handle to an open file. ‘$h’ is a generic handle and the meaning depends on context. ‘$dbh’ is a handle to a database object. ‘$sth’ is a handle to a query object.

7. Which variable is a handle to a database object?
a) $dbh
b) $sth
c) $fh
d) $h
View Answer

Answer: a
Explanation: The variable named ‘$dbh’ is a handle to an open file. ‘$h’ is a generic handle and the meaning depends on context. ‘$dbh’ is a handle to a database object. ‘$sth’ is a handle to a query object.
advertisement

Sanfoundry Global Education & Learning Series – MySQL Database.

To practice all areas of MySQL Database, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.