Questions about the type of sql data

Asked

Viewed 23 times

0

What is the best type of sql data should I use for values in case of inclusion of product notes? The notes range from: 1.0, 1.5,... to 10.0. I have been thinking about using Double, but I don’t know if it would be ideal. For monetary values I use DECIMAL(10,2), but it wouldn’t be the case. I am using Mysql.

  • 1

    As shown there depends on whether you want accuracy or not. Generally I just do not use the decimal if you have a very strong reason.

  • 2

    If it’s "note" in the sense of punctuation and you really want to "brush bits", and it’s . 5 in . 5, can use an integer of 1 byte only, and double the scale (do from 0 to 20, where the real value is half - 1 = 0.5 point, 2 = 1 point, 5 = 2.5 points. etc) - it remains to be seen whether you really need it. Ai when storing, SET noteupla = note * 2, and when picking SELECT noteupla / 2 AS note (still, I don’t know if it justifies instead of decimal)

  • Hello Bacco. Actually I put 1.0, 1.5 as an example, because the note will be from 1.0 to 10.0, can be 1.4, 2.7, etc.

  • @Fox.11 that is, the scale can be from 0 to 100.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.