Mysql data type for multiple decimal points
I need to store some data in the following format:
1.2
1.2.1
1.2.2
1.3
etc..
I highly suspect that I must use varchar for this, but my guy says that it's still some kind of int. It's for a catalogue hierarchy system.
Google is leading me no where.. 开发者_运维百科Anyone done this before?
I don't think there is a numeric format that works for these.
Abusing a DECIMAL
won't lead anywhere, as you won't be able to tell apart 1.2.11
and 12.1.1
.
I would store them in a VARCHAR
.
If you need to store "1.2.2" then its a string. If you had a table of "IDs" where you could have "itemID" and "ParentID" then you could do it with integers as then the Uid, for 1.2 could be the number 23, ergo would be integers, but it doesnt save you as you would then need recursive to find the full path.
When you have many of this numbers and set of numbers can be long, you can use some dictionary in other table to handle it, and carry only pointer.
But i think too VARCHAR
is optimal when you DONT WANT search over this numbers eg. where second number is 13, then my solution is better.
精彩评论