MYSQL Workbench Column Default/Expression

MySQLmysql-workbench

MYSQL Workbench Column Default/Expression

What can be put in here, I see I can put in a default value for the field

Can I also put mysql statements? Or is this just for default values?

For a Column detail, if I check the "G" for generate it will create a statement

GENERATED ALWAYS AS () VIRTUAL , 

What does this mean, and where can I find documentation on how to use this?

Best Answer

You are kind of mixing 2 different topics.

  • DEFAULT clause only accepts constants in MySQL. For example 0, -1, '', or '2000-01-01'. Workbench cannot override this limitation.
  • Virtual columns may be what you really need (or not). They have an automatic value determined by an SQL expression (no queries), but you cannot change that value. Check this article for more details.