gpt4 book ai didi

php - SQL Alter Table 语法错误

转载 作者:行者123 更新时间:2023-11-29 00:28:42 25 4
gpt4 key购买 nike

--Rev19
ALTER TABLE `staff` MODIFY `role` enum('admin', 'employee', 'guest');
ALTER TABLE `staff` ALTER `role` SET DEFAULT 'guest';

它说:

#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 '--Rev19
ALTER TABLE `staff` MODIFY `role` enum('admin', 'employee', 'guest')' at line 1

这里有什么问题吗?附带说明一下,为什么 SQL 错误报告必须如此糟糕,大多数语言会告诉您 SQL 只是说的特定语法错误,请查看手册。

最佳答案

来自手册:

From a “-- ” sequence to the end of the line. In MySQL, the “-- ” (double-dash) comment style requires the second dash to be followed by at least one whitespace or control character (such as a space, tab, newline, and so on).

所以只需在 -- 之后添加一个空格就可以了。

关于php - SQL Alter Table 语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17659290/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com