0
0
MySQLquery~5 mins

Time zone handling in MySQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
ATIMESTAMP
BDATETIME
CTIME
DDATE
How do you set the global time zone in MySQL?
ASET time_zone = 'timezone';
BALTER DATABASE time_zone = 'timezone';
CSET GLOBAL time_zone = 'timezone';
DSET SESSION time_zone = 'timezone';
What happens if you store a date/time value in a DATETIME column in MySQL?
AIt is stored in UTC and converted on retrieval.
BIt is stored as-is without time zone conversion.
CIt is automatically converted to the server's time zone.
DIt is rejected if not in UTC.
Which command shows the current session time zone in MySQL?
ASHOW VARIABLES LIKE 'time_zone';
BSHOW TIMEZONE;
CSELECT @@global.time_zone;
DSELECT @@session.time_zone;
Why is it important to load time zone tables in MySQL?
ATo enable time zone conversions for TIMESTAMP data.
BTo speed up queries.
CTo allow storing dates before 1970.
DTo enable encryption of date/time data.
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.