在 MySQL 中将 BigInt 转换为 Varchar

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8259350/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 21:49:01  来源:igfitidea点击:

Cast/Convert BigInt to Varchar in MySQL

mysql

提问by InfZero

How might I Cast/Convert BigInt to Varchar in MySQL?

我如何在 MySQL 中将 BigInt 转换/转换为 Varchar?

回答by ajreal

mysql> select  Cast( 12345678901234567890 as char) ;
+-------------------------------------+
| Cast( 12345678901234567890 as char) |
+-------------------------------------+
| 12345678901234567890                | 
+-------------------------------------+

回答by golimar

I think you can't cast to varchar, try charinstead. Or are you trying to modify the type of an existing field of a table? Then you have to do for example:

我认为你不能投射到varchar,请尝试char。或者您是否正在尝试修改表的现有字段的类型?然后你必须做例如:

ALTER TABLE MODIFY COLUMN mycolumn varchar(50);

ALTER TABLE MODIFY COLUMN mycolumn varchar(50);