这是代码
CREATE TABLE `church` (
`ID` int(10) UNSIGNED NOT NULL,
`StudentID` int(11) NOT NULL,
`semesterID` int(11) NOT NULL,
`attendedWed` int(11) NOT NULL,
`attendedFri` int(11) NOT NULL,
`attendedSabM` int(11) NOT NULL,
`attendedSabE` int(11) NOT NULL,
`ChurchScore` double(10,2) GENERATED ALWAYS AS ((((((`attendedWed` + `attendedFri`) + `attendedSabM`) + `attendedSabE`) * 100) / 60)) STORED
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
这是错误
Operation failed: There was an error while applying the SQL script to the database. Executing: ALTER TABLE
citizenshipgroup3
.church
CHANGE COLUMNChurchScore
ChurchScore
DOUBLE(10,2) NULL DEFAULTattendedWed
;ERROR 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '
attendedWed
' at line 2 SQL Statement: ALTER TABLEcitizenshipgroup3
.church
CHANGE COLUMNChurchScore
ChurchScore
DOUBLE(10,2) NULL DEFAULTattendedWed
最佳答案
你的语法没问题。问题是 MySQL 直到 5.7 才支持生成的列。您可能使用的是早期版本。
可能最简单的解决方案是使用 View 进行计算。
关于mysql - 生成的存储过程失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53467871/