"how to store version number in mysql database" Code Answer

2

you have 2 options:

  1. use varchar

  2. use three numeric fields, major, minor, patch

  3. use both.

each option has its advantages and disadvantages.

option 1 is only one field, so it's easy to get the version. but it isn't necessarily sortable, since 2.0.0 will be lexicographically higher than 10.0.0.

option 2 will be easily sortable, but you have to get three fields.

option 3 can be implemented using a view:

table tversion (
  major number(3),
  minor number(3),
  patch number(3)
)

view vversion is 
  select major || '.' || minor || '.' || patch as version,
         major * 1000000 + minor * 1000 + patch as sortorder from tversion;
By Rick Doesburg on March 7 2022

Answers related to “how to store version number in mysql database”

Only authorized users can answer the Search term. Please sign in first, or register a free account.