An error occurred trying to load this video.

Try refreshing the page, or contact customer support.

Coming up next: SQL Data Types: BOOLEAN

You're on a roll. Keep up the good work!

Take Quiz Watch Next Lesson
Your next lesson will play in 10 seconds
  • 0:02 SQL Data Types
  • 0:59 The Real & Float Data Types
  • 2:12 The Double Data Type
  • 3:30 Lesson Summary
Save Save Save

Want to watch this again later?

Log in or sign up to add this lesson to a Custom Course.

Log in or Sign up

Speed Speed

Recommended Lessons and Courses for You

Lesson Transcript
Instructor: Martin Gibbs

Martin has 16 years experience in Human Resources Information Systems and has a PhD in Information Technology Management. He is an adjunct professor of computer science and computer programming.

Data, data everywhere, but which type should I use? In the era of large data and big numbers, it's important to understand the various data types available in SQL. This lesson covers three: real, float, and double.

SQL Data Types

They may sound like menu items at a malt shop, but real, float, and double are data types supported by SQL and other programming languages. Once you learn these, you'll have a good foundation for other tools as well.

Each data type is considered an approximate value because their usage in SQL revolves around precision. An easy way to think of precision is to visualize the number of digits after the decimal point of a complex number. Many calculations result in nice, easy numbers (say 11.55); while others, such as 1 divided by 3, create very long numbers. Precision asks: How many numbers do you want to see? In some cases, the numbers are infinite; in others they are just too long to have any functional use.

In computer terms, precision is also the number of bytes a number will hold. We will talk about each data type in terms of bytes allowed but also show how those data types are used in a practical manner.

The Real & Float Data Types

Real data can hold a value 4 bytes in size, meaning it has 7 digits of precision (the number of digits to the right of the decimal point). It's also a floating-point numeric that is identical to the floating point statement float(24).

Like the real data type, float data is approximate: float can hold 8 bytes, or 15 places after the decimal point. Note that each database (MySQL, SQL Server) has different implementations. In older versions of MySQL, (pre-8.0.17) you could specify precision for float; that is, how many digits to show after the decimal point. This was done using float(size,d) where size was the total number of digits and d the number of digits after the decimal point.

In current versions, float is expressed as float(n). The n value will determine if the value is kept as float or changed to double. That is, if n is between 0 and 24, the value remains float; otherwise MySQL converts to double.

The syntax for float in SQL Server is float(n). In this case, the n indicates if the field will take up 4 or 8 bytes. The default value of n is 53, meaning it will store 8 bytes.

The Double Data Type

In MySQL, the double data type is similar to the float, except that the double allows for much larger numbers. Let's look at a real-world application for the double data type.

To unlock this lesson you must be a Study.com Member.
Create your account

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use Study.com

Become a Study.com member and start learning now.
Become a Member  Back
What teachers are saying about Study.com
Try it risk-free for 30 days

Earning College Credit

Did you know… We have over 200 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Transferring credit to the school of your choice

Not sure what college you want to attend yet? Study.com has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

Create an account to start this course today
Try it risk-free for 30 days!
Create an account