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.
advertisement

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.

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.
advertisement

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’.

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
advertisement
advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn