You have 2 options:
Use varchar
Use three numeric fields, Major, Minor, Patch
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;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…