Wouldn't it be cool to enhance MySQL creation table syntax to do
this?
CREATE TABLE t1 (
my_date DATE,
my_month VIRTUAL INT AS (DATE_FORMAT(d,'%Y%m'))
);
And later, when you insert '2008-08-23' in my_date, then
automatically my_month will be set to 200808.
Yes, it would be cool, and it has been done. Andrey
Zhakov, a so far unknown to me community contributor, has
extended the server code to implement virtual columns (WL#411) and functional indexes (WL#1075)
Andrey has published …