0

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?

  • 1
    Did you search MySQL documentation about generated columns? Workbench is a just a (nice and graphical) interface to interact with mysql server. It can create statements for you (CREATE TABLE, ALTER TABLE etc) but it's much more helpful for learning to write them yourself, getting advice and examples from the docs. – ypercubeᵀᴹ Feb 28 '18 at 19:49
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.