简体   繁体   English

在MySQL数据库中存储工作日的最佳方法

[英]Best way to storing week days in MySQL database

I would like to know the most efficient datatype of storing days ( SUNDAY, MONDAY etc.) of the week in a MySQL database. 我想知道在MySQL数据库中存储一周中的某天( 周日,周一等)的最有效数据类型。 I want to search using that field and it will be used frequently. 我想使用该字段进行搜索,它将经常使用。

I want to show the days as SUNDAY, MONDAY etc. in the GUI also. 我也想在GUI中将日期显示为SUNDAY,MONDAY等。 So, is it ok to use VARCHAR and store it as same as the name of the day or store it as TINYINT and convert when showing in the GUI? 因此,可以使用VARCHAR并将其存储为与星期相同的名称或将其存储为TINYINT并在GUI中显示时进行转换吗?

I think it should be 我认为应该

CREATE TABLE DAY_TABLE
(
 -- other fields
  EVENT_DAY ENUM('SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY')
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM