Wouldn't it be cool to enhance MySQL creation table syntax to do this?
And later, when you insert '2008-08-23' in my_date, then automatically my_month will be set to 200808.
CREATE TABLE t1 (
my_month VIRTUAL INT AS (DATE_FORMAT(d,'%Y%m'))
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 ( [Read more...]