本文介绍了MySQL 5.1.41前导零被删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MySQL数据库,我想在其中存储电话号码.

I have a MySQL database where I want to store phone numbers among other things.

字段类型为INT(10)

The fieldtype is INT(10)

当我尝试插入以0开头的数字时(例如0504042858),其存储方式为504042858.这仅发生在带有前导零的电话号码中.如果该数字以其他任何数字开头,则表示该数字已正确存储.

When I try to insert a number starting with a 0, like 0504042858 it's stored like 504042858. This only happens with phone numbers with leading zeros. When the number start with any other number, it's stored correctly.

我在做什么错了?

推荐答案

您可能应该将电话号码存储为varchar.电话号码只是偶然的数字.

You should probably store phone numbers as a varchar. Phone numbers are only numeric by accident.

您可能也有兴趣查看以下Stack Overflow帖子:

You may also be interested in checking out the following Stack Overflow posts:

  • What datatype should be used for storing phone numbers in SQL Server 2005?
  • Common MySQL fields and their appropriate data types

这篇关于MySQL 5.1.41前导零被删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 19:24