解决办法:
From MySQL documentation 13.1.18.7 CREATE TABLE and Generated Columns:
Generated column expressions must adhere to the following rules. An error occurs if an expression contains disallowed constructs.
Literals, deterministic built-in functions, and operators are permitted. A function is deterministic if, given the same data in tables, multiple invocations produce the same result, independently of the connected user. Examples of functions that are nondeterministic and fail this definition: CONNECTION_ID(), CURRENT_USER(), NOW().
翻译:
rand()函数每次会产生不同结果,所以是不允许的