How to save version number in MySQL database

I want to save the version number of my application in a MySQL database for ex:

version 1.1.0 1.1.1 1.1.2

What type of data should I use.

+8
sql database php mysql
source share
3 answers

You have 2 options:

  • Use varchar

  • Use three number fields: Major, Minor, Patch

  • Use both options.

Each option has its advantages and disadvantages.

Option 1 is just one field, so it's easy to get. But it is not necessarily sorted, since 2.0.0 will be lexicographically higher than 10.0.0.

Option 2 will be easy to sort, but you should get three fields.

Option 3 Can be implemented using the 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; 
+9
source share

It is always better to use VARCHAR when storing different version numbers.

+1
source share

You can use varchar() or even use INET_NTOA . Try LINK

0
source share

All Articles