Recall & Review
beginner
What is the purpose of time zone handling in MySQL?
Time zone handling ensures that date and time values are stored, retrieved, and displayed correctly according to different geographic locations.
Click to reveal answer
beginner
How do you set the time zone for the current MySQL session?
Use the command:
SET time_zone = 'timezone'; For example, SET time_zone = '+00:00'; sets UTC time zone for the session.Click to reveal answer
intermediate
What is the difference between
TIMESTAMP and DATETIME types in MySQL regarding time zones?TIMESTAMP stores values in UTC and converts to the session time zone on retrieval. DATETIME stores values as-is without time zone conversion.Click to reveal answer
beginner
How can you check the current global and session time zones in MySQL?
Run these queries:<br>
SELECT @@global.time_zone;<br>SELECT @@session.time_zone;Click to reveal answer
beginner
Why is it recommended to store timestamps in UTC in databases?
Storing timestamps in UTC avoids confusion and errors when users or applications in different time zones access the data. It ensures consistent and reliable time data.
Click to reveal answer
Which MySQL data type automatically converts stored time to UTC and back to session time zone on retrieval?
✗ Incorrect
TIMESTAMP stores values in UTC and converts them based on the session time zone.How do you set the global time zone in MySQL?
✗ Incorrect
Use
SET GLOBAL time_zone = 'timezone'; to set the global time zone.What happens if you store a date/time value in a DATETIME column in MySQL?
✗ Incorrect
DATETIME stores the value exactly as given, without any time zone conversion.Which command shows the current session time zone in MySQL?
✗ Incorrect
SELECT @@session.time_zone; returns the current session's time zone.Why is it important to load time zone tables in MySQL?
✗ Incorrect
Time zone tables provide the data needed for MySQL to convert times correctly between zones.
Explain how MySQL handles time zones when storing and retrieving TIMESTAMP and DATETIME values.
Think about how time zone affects storage and display differently for these types.
You got /4 concepts.
Describe the steps to set and check the time zone for a MySQL session.
Remember session vs global settings.
You got /3 concepts.