Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

Storing Long Numbers in a MySQL Database - What data type do I use

Hi There,

I am capturing long numbers of around 20-30 digits long and I want to capture this into a mySQL database. I am currently using int(50) to capture this but as soon as the character count goes over 10 it defaults to this number in the database when added:

2147483647

First I am wondering why this is happening and defaulting to THAT number?
Second How do I fix this problem ( I am sure I have done this same thing in the past the exact same way and it has worked perfectly).

Thanks - Look forward to your answers,
George
0
George-TCC
Asked:
George-TCC
1 Solution
 
Patrick MatthewsCommented:
Hello George-TCC,

The int data type cannot hold a value larger than 2^31 - 1, which is 2147483647.  That 50 in int(50) refers to
the display width, and has no bearing on the size of the number that can be stored.

If you want to store a 30-digit number, you should use the decimal or numeric data types instead.

See:
http://www.ispirer.com/wiki/sqlways/mysql/data-types

Regards,

Patrick
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now