To choose a temporal data type, consider questions such as these:
• Do you need times only, dates only, or combined date and time values?
• What range of values do you require?
• Do you want automatic initialization of the column to the current date and time?
MySQL provides DATE and TIME data types for representing date and time values separately,
and DATETIME and TIMESTAMP types for combined date-and-time values. These
values have the following characteristics:
• DATE values have CCYY-MM-DD format, where CC, YY, MM, and DD represent the century,
year within century, month, and day parts of the date. The supported range for DATE
values is 1000-01-01 to 9999-12-31.
• TIME values have hh:mm:ss format, where hh, mm, and ss are the hours, minutes,
and seconds parts of the time. TIME values often can be thought of as time-of-day
values, but MySQL actually treats them as elapsed time. Thus, they may be greater
than 23:59:59 or even negative. (The actual range of a TIME column is -838:59:59
to 838:59:59.)
• DATETIME and TIMESTAMP are combined date-and-time values in CCYY-MM-DD
hh:mm:ss format.
The DATETIME and TIMESTAMP data types are similar in many respects, but watch
out for these differences:
—DATETIME has a supported range of 1000-01-01 00:00:00 to 9999-12-31
23:59:59, whereas TIMESTAMP values are valid only from the year 1970 partially
through 2038.
—TIMESTAMP and DATETIME have special auto-initialization and auto-update properties
(see Recipe 6.7), but for DATETIME they are not available before MySQL
5.6.5.
—When a client inserts a TIMESTAMP value, the server converts it from the time
zone associated with the client session to UTC and stores the UTC value. When
the client retrieves a TIMESTAMP value, the server performs the reverse operation
to convert the UTC value back to the client session time zone. A client in a time
zone different from the server can configure its session so that this conversion
is appropriate for its own time zone (see Recipe 6.4).
• Types that include a time part can have a fractional seconds part for subsecond
resolution (see Recipe 6.2).
To choose a temporal data type, consider questions such as these:• Do you need times only, dates only, or combined date and time values?• What range of values do you require?• Do you want automatic initialization of the column to the current date and time?MySQL provides DATE and TIME data types for representing date and time values separately,and DATETIME and TIMESTAMP types for combined date-and-time values. Thesevalues have the following characteristics:• DATE values have CCYY-MM-DD format, where CC, YY, MM, and DD represent the century,year within century, month, and day parts of the date. The supported range for DATEvalues is 1000-01-01 to 9999-12-31.• TIME values have hh:mm:ss format, where hh, mm, and ss are the hours, minutes,and seconds parts of the time. TIME values often can be thought of as time-of-dayvalues, but MySQL actually treats them as elapsed time. Thus, they may be greaterthan 23:59:59 or even negative. (The actual range of a TIME column is -838:59:59to 838:59:59.)• DATETIME and TIMESTAMP are combined date-and-time values in CCYY-MM-DDhh:mm:ss format.The DATETIME and TIMESTAMP data types are similar in many respects, but watchout for these differences:—DATETIME has a supported range of 1000-01-01 00:00:00 to 9999-12-3123:59:59, whereas TIMESTAMP values are valid only from the year 1970 partiallythrough 2038.—TIMESTAMP and DATETIME have special auto-initialization and auto-update properties(see Recipe 6.7), but for DATETIME they are not available before MySQL5.6.5.—When a client inserts a TIMESTAMP value, the server converts it from the timezone associated with the client session to UTC and stores the UTC value. Whenthe client retrieves a TIMESTAMP value, the server performs the reverse operationto convert the UTC value back to the client session time zone. A client in a timezone different from the server can configure its session so that this conversionis appropriate for its own time zone (see Recipe 6.4).• Types that include a time part can have a fractional seconds part for subsecondresolution (see Recipe 6.2).
การแปล กรุณารอสักครู่..

ในการเลือกชนิดของข้อมูลชั่วคราวพิจารณาคำถามเช่นนี้:
? •คุณต้องการเวลาเพียงวันเดียวหรือรวมวันที่และค่าเวลา
•อะไรช่วงของค่าที่ทำคุณต้องการ?
•คุณต้องการเริ่มต้นโดยอัตโนมัติจากคอลัมน์ วันและเวลาปัจจุบัน?
MySQL ให้วันที่และชนิดข้อมูลเวลาในการคิดเป็นค่าวันที่และเวลาแยก
และ DATETIME และประเภทลงเวลาสำหรับการรวมค่าวันที่และเวลา เหล่านี้
ค่ามีลักษณะดังต่อไปนี้:
ค่า•วันที่มีรูปแบบ Ccyy-MM-DD ที่ CC, YY, MM และ DD แทนศตวรรษ
ปีภายในศตวรรษที่, เดือน, และชิ้นส่วนวันนับจากวันที่ ช่วงวันที่ได้รับการสนับสนุน
ค่าเป็น 1000/01/01 เพื่อ 9999-12-31.
•ค่าเวลาที่มี hh: mm: รูปแบบเอสเอสที่ hh, มมและเอสเอสเป็นชั่วโมงนาที
และวินาทีส่วนของเวลา เวลาค่ามักจะคิดว่าเป็นเวลาของวัน
ค่า แต่ MySQL จริงถือว่าพวกเขาเป็นเวลาที่ผ่านไป ดังนั้นพวกเขาอาจจะสูง
กว่าหรือแม้กระทั่ง 23:59:59 เชิงลบ (ช่วงที่แท้จริงของการเป็นคอลัม -838 เวลา: 59: 59
ไป 838: 59: 59.)
DATETIME •และลงเวลาจะรวมค่าวันที่และเวลาในการ Ccyy-MM-DD
hh: mm. รูปแบบเอสเอส
DATETIME และชนิดของข้อมูลที่ลงเวลามีความคล้ายคลึงกันในหลายประการ แต่ดู
ออกสำหรับความแตกต่างเหล่านี้:
-DATETIME มีช่วงที่ได้รับการสนับสนุนของ 1000/01/01 00:00:00 ไป 9999-12-31
23:59:59, ในขณะที่ค่าลงเวลาเป็น ใช้ได้เฉพาะจากปี 1970 บางส่วน
ผ่าน 2038.
-TIMESTAMP และ DATETIME มีพิเศษเริ่มต้นอัตโนมัติและคุณสมบัติการอัพเดทอัตโนมัติ
(ดูสูตร 6.7) แต่สำหรับ DATETIME พวกเขาจะไม่สามารถใช้ได้ก่อน MySQL
5.6.5.
เมื่อมีลูกค้าแทรกลงเวลา ค่าเซิร์ฟเวอร์แปลงจากเวลาที่
โซนที่เกี่ยวข้องกับเซสชั่นลูกค้าที่จะ UTC และเก็บค่า UTC เมื่อ
ลูกค้าเรียกค่าเวลาของเซิร์ฟเวอร์ดำเนินการดำเนินการย้อนกลับ
การแปลงค่า UTC กลับไปยังลูกค้าโซนเวลาในเซสชั่ ลูกค้าในเวลา
ที่แตกต่างกันโซนจากเซิร์ฟเวอร์สามารถกำหนดค่าเซสชั่นเพื่อให้การแปลงนี้
เป็นที่เหมาะสมสำหรับโซนเวลาของตัวเอง (ดูสูตร 6.4).
•ประเภทที่มีเวลาส่วนหนึ่งสามารถมีส่วนหนึ่งวินาทีเศษสำหรับ subsecond
ความละเอียด (ดูสูตร 6.2)
การแปล กรุณารอสักครู่..
