mysql数据库中的查询有什么问题?

时间:2022-03-13 00:07:13

I am trying to create a table in mysql database by running below query,

我尝试在mysql数据库中创建一个表,运行如下查询,

CREATE TABLE vms_schedule(
   schedule_id Int AUTO_INCREMENT
   ,   name varchar(255) NOT NULL
   ,   start_date timestamp NOT NULL
   ,   end_date timestamp NOT NULL
   ,   sun Numeric(10, 0) 
   ,   mon Numeric(10, 0) 
   ,   tue Numeric(10, 0) 
   ,   wed Numeric(10, 0) 
   ,   thu Numeric(10, 0) 
   ,   fri Numeric(10, 0) 
   ,   sat Numeric(10, 0) 
   ,PRIMARY KEY (schedule_id)
);

But I am getting "Invalid default value for end_date" error. Not sure what is wrong with the query as it works for start_date and not for end_date.

但是我得到的是“end_date的无效默认值”错误。不确定查询对于start_date而不是end_date有什么问题。

EDIT: mysql数据库中的查询有什么问题?

编辑:

Thanks.

谢谢。

1 个解决方案

#1


2  

I cannot reproduce this problem on MySQL 5.6.23. I don't have MySQL 5.7. 5.7 is a development release. You probably shouldn't be using it for production. You probably hit a bug and you should report it.

我无法在MySQL 5.6.23上重现这个问题。我没有MySQL。7。5.7是一个开发版本。您可能不应该将它用于生产。你可能碰到了一个bug,你应该报告它。

I would avoid TIMESTAMP and use DATETIME instead. TIMESTAMP has many odd and confusing "features" and is limited to dates between 1970 and 2038. Its simpler and more robust to use DATETIME and declare any magic you want to happen explicitly.

我将避免时间戳,而是使用DATETIME。时间戳有许多奇怪而令人困惑的“特性”,并且仅限于1970年至2038年之间的日期。使用DATETIME并声明您希望显式发生的任何魔术,它更简单、更健壮。

#1


2  

I cannot reproduce this problem on MySQL 5.6.23. I don't have MySQL 5.7. 5.7 is a development release. You probably shouldn't be using it for production. You probably hit a bug and you should report it.

我无法在MySQL 5.6.23上重现这个问题。我没有MySQL。7。5.7是一个开发版本。您可能不应该将它用于生产。你可能碰到了一个bug,你应该报告它。

I would avoid TIMESTAMP and use DATETIME instead. TIMESTAMP has many odd and confusing "features" and is limited to dates between 1970 and 2038. Its simpler and more robust to use DATETIME and declare any magic you want to happen explicitly.

我将避免时间戳,而是使用DATETIME。时间戳有许多奇怪而令人困惑的“特性”,并且仅限于1970年至2038年之间的日期。使用DATETIME并声明您希望显式发生的任何魔术,它更简单、更健壮。