What are the uses of the int, Money, Decimal, Numeric, Float and Real Data, data types in the database?

What are the uses of the int, Money, Decimal, Numeric, Float and Real Data, data types in the database?

Default featured image

What are the uses of the int, Money, Decimal, Numeric, Float and Real Data, data types in the database?

In the Relational Database Management System (RDBMS) we have so many data types in SQL Server and ORACLE database. There are so many important data types i.e. int, Money, Decimal, Numeric, Float and Real Data which we use for most of the time in the database. Let discuss more about these data types in detail to understand the importance and use in the database.

1) Decimal: – This data type can hold up to 38 digits. The reason for using this data type is that we can store the exact value of the given number in the database. This value will not be the approximation of any number. We can use the decimal data type when we need to store the exact values as mentioned or specified.

Decimal column can be defined as the combination of the two thing which are variable and parameters to specify the precision (No. of digits the column can hold) and also to specify the scale (No. of digits can be placed to the right of the decimal point).

2) Numeric: – In the Transact SQL numeric is similar to the decimal data type at the function level. It can also store the 38 digits of numbers in it.

3) Float: – This data type is well known for approximate number. The approximate numeric data type cannot hold the exact value of the given numbers. The value stored in this data type will be approximate but not the exact even though the difference is negligible. We should avoid using this data type in case of financial application, in operation involving rounding. We should go for using int, money and decimal as data type instead of float.

4) Real Data: – This data type is also known as approximate number. The approximate numeric data type cannot hold the exact value of the given numbers. The value stored in this data type will be approximate but not the exactly similar to the decimal and numeric, even though the difference is negligible. We should avoid using this data type in case of financial application, in operation involving rounding. We should go for using int, money and decimal as data type instead of Real Data

We should not use the Real Data and Float types of the data type in case of the using = or <> operators in the where clause condition. Because these two data types are not accurate. We can use these two data types in the greater than (>) or less than (< ) comparison. 5) Money and Smallmoney: - These are the data types to store the monetary or currency values in the data type. Money data type stores the 8 bytes and Smallmoney data type stores the 4 bytes. These data types are capable to store the ten-thousandth of the monetary unit. For example:- cents and dollars etc. 6) Int, bigint, smallint and tinyint:- These data types can also stores the exact values of the number. int data type is the primary integer data type in the SQL Server. We can use the bigint data type in place of the int and small int if the records are too much in the given table. But if the data is keep increasing in the table then we can change the data type of the monetary column into bigint from tinyint, smallint and int. The use of the different data type from the int family is used as per the requirements which are different all the time. For Metadata/ Base tables may be able to use the tinyint and smallint but for the transaction tables we can go for the int and bigint data types. Thanks, Sandeep Rajmail World of Mechatronics

Comments

One response to “What are the uses of the int, Money, Decimal, Numeric, Float and Real Data, data types in the database?”

  1. […] What are the uses of the int, Money, Decimal, Numeric, Float and Real Data, data types in the databa… […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post