mysql -虚拟列
● 5.7 版本以上;
CREATE TABLE test_vitrual_column(
`id` int(40) NOT NULL AUTO_INCREMENT COMMENT 'ID ',
`stat_date` date DEFAULT null ,
day_of_week TINYINT(4) GENERATED ALWAYS AS (dayofweek(stat_date)) VIRTUAL,
PRIMARY KEY (`id`),
UNIQUE key inq_stat_date(stat_date),
key ind_day_of_week (day_of_week)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='测试表';