Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL ; Best data type for large numbers

I want to store a field which stores channel clicks per day( increasing every second and updated in a day) into MySQL DB table. What datatype should I assign to the column keeping in mind that it can even be less than 100 or can even exceed a million.

like image 694
Danish Bin Sofwan Avatar asked Sep 20 '16 08:09

Danish Bin Sofwan


People also ask

What datatype is used for large numbers?

Longer integers: long The long data type stores integers like int , but gives a wider range of values at the cost of taking more memory. Long stores at least 32 bits, giving it a range of -2,147,483,648 to 2,147,483,647. Alternatively, use unsigned long for a range of 0 to 4,294,967,295.

What is the biggest data type in MySQL?

The largest character data type in MySql is LONGTEXT (see Storage Requirements for String Types), that is capable to hold 2^32-1 bytes.

Which numeric data type has the largest range in MySQL?

Explanation: Longtext has largest range.

Can MySQL handle large data?

MySQL was not designed for running complicated queries against massive data volumes (which requires crunching through a lot of data on a huge scale). MySQL optimizer is quite limited, executing a single query at a time using a single thread.


1 Answers

MySQL Integer Types (Exact Value):

enter image description here

Fixed-Point Types (Exact Value) - DECIMAL, NUMERIC:

In standard SQL, the syntax DECIMAL(M) is equivalent to DECIMAL(M,0). Similarly, the syntax DECIMAL is equivalent to DECIMAL(M,0), where the implementation is permitted to decide the value of M. MySQL supports both of these variant forms of DECIMAL syntax. The default value of M is 10.

If the scale is 0, DECIMAL values contain no decimal point or fractional part.

The maximum number of digits for DECIMAL is 65, but the actual range for a given DECIMAL column can be constrained by the precision or scale for a given column. When such a column is assigned a value with more digits following the decimal point than are permitted by the specified scale, the value is converted to that scale. (The precise behavior is operating system-specific, but generally the effect is truncation to the permissible number of digits.)

Storage Requirements:

enter image description here


enter image description here

like image 102
Drew Avatar answered Nov 18 '22 06:11

Drew