?
Solved

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

Posted on 2010-01-12
1
Medium Priority
?
177 Views
Last Modified: 2013-12-12
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
Comment
Question by:George-TCC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 2000 total points
ID: 26299958
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this article, we’ll look at how to deploy ProxySQL.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
The viewer will learn how to dynamically set the form action using jQuery.

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question