【发布时间】:2023-04-01 14:58:01
【问题描述】:
请原谅我糟糕的英语 这是我的sql
create table if not exists `test` (
`client_id` varchar(18) not null default ' ',
`begin_date` int not null default DATE_FORMAT(sysdate() ,'%Y%m%d') ,
`end_date` int not null default DATE_FORMAT(sysdate() ,'%Y%m%d'),
unique index `uk_key` (`client_id` asc)
) engine = InnoDB default charset = utf8 collate = utf8_bin comment = '';
commit;
在10.3.18-MariaDB-log中,执行后没有报错 但是在Mysql 8.0.22中,报错
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DATE_FORMAT(sysdate() ,'%Y%m%d'),
`end_date` int not nu' at line
被举报;
我修改了@global.sql_mode 和@sql_mode,但是没有用。
+-----------------------------------------------------------------------+
| @@sql_mode |
+-----------------------------------------------------------------------+
| STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |
mysql> select @@global.sql_mode;
+-----------------------------------------------------------------------+
| @@global.sql_mode |
+-----------------------------------------------------------------------+
| STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |
+-----------------------------------------------------------------------+
我该怎么办 ????
【问题讨论】:
-
我想在 mysql 8 whitout 错误中执行这个 sql,就像在 10.3.18-MariaDB-log 中一样
标签: mysql default date-format mysql-8.0