user3841111 user3841111 - 1 year ago 147
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download