HomeНаука и техникаRelated VideosMore From: Caleb Curry

MySQL 31 - DECIMAL Data Type

189 ratings | 8833 views
The DECIMAL data type is similar to the INT data type in that when you use the number for math, it maintains precision. The difference though is obvious in the name. The DECIMAL data type allows for numbers after a decimal point (and before the decimal point). The DECIMAL data type allows us to store what is known as a fixed-point number. A fixed point number is a number that has a specific number of digits available to store numbers in. That means we can't do things like use a DECIMAL data type to store as many digits of PI as possible, because we can't store unlimited digits. We are limited to a certain number. There are two keywords you need to understand when you are working with the DECIMAL data type, precision and scale. Precision is the number of digits and scale is the number of those digits that will come after the radix. You are going to want to provide these numbers when you declare a column of this data type. For example, DECIMAL(5, 2) has a precision of 5 digits and a scale of 2 digits. That means we can store a maximum of two digits after the decimal and four digits total. This gives us a possible range from -999.99 to 999.99 The highest number of digits is 65, and the highest number of digits after the decimal is 30. This data type is also known as DEC, NUMERIC, and FIXED. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support me! http://www.patreon.com/calebcurry Subscribe to my newsletter: http://bit.ly/JoinCCNewsletter Donate!: http://bit.ly/DonateCTVM2. ~~~~~~~~~~~~~~~Additional Links~~~~~~~~~~~~~~~ More content: http://CalebCurry.com Facebook: http://www.facebook.com/CalebTheVideoMaker Google+: https://plus.google.com/+CalebTheVideoMaker2 Twitter: http://twitter.com/calebCurry Amazing Web Hosting - http://bit.ly/ccbluehost (The best web hosting for a cheap price!)
Html code for embedding videos on your blog
Text Comments (14)
Pirates Skull (21 days ago)
Priyanka Shaw (1 month ago)
How can I accept a decimal value from user using Scanner class?
consciousprogrammer (7 months ago)
Thank you very much, like and subscribe you go.
Niels (10 months ago)
Ptmp727 (11 months ago)
Saved my life at 3am, when I was working like the immortal myth :) But my workbench fails when i have decimal type 5,2 when I try to insert a value of 160.00, says out of bounds
Icaras12x (1 year ago)
Thank you
MGTEKNS (1 year ago)
Thank you 🙏
Javier Custodio Ore (1 year ago)
Luis Mata (1 year ago)
Quite easy to understand, thanks
astetik boi (1 year ago)
Fire ass vids
White Mapper (2 years ago)
Thank you so much, you helped me a lot with this video :)
Caleb Curry (2 years ago)
Thank you for the nice comment! :) Im glad I could help.
GormGear (2 years ago)
Fantastic explanation, helped me get over an issue with some lecture notes when working with the INT datatype instead.
GandhiAndy (2 years ago)
Thank you the M AND D part of Decimal(m,d) was confusing me. :)

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.