user3841111 user3841111 - 9 months ago 62
MySQL Question

MySQL function in column default value

Is it possible to use function in column default value?

I want to do something like that:

col1 varchar(100),
col2 varchar(1) NOT NULL DEFAULT SUBSTRING(col1,1,1)

Answer Source

No, that is not possible.

Only static values are allowed and times values like current_timestamp or current_date.