将 MySQL 中的列从 int 更改为 double?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10322109/
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 13:07:07  来源:igfitidea点击:

Changing Column in MySQL from int to double?

mysqlsyntaxintdouble

提问by Lolmewn

Basically, I currently have a column in a MySQL table, which is an int.

基本上,我目前在 MySQL 表中有一个列,它是一个 int。

I'd like to change that to double. I've searched the web, but all it came up with was conversion upon getting the values from the column (like converting some date to Date), but that's not what I mean.

我想把它改成两倍。我在网上搜索过,但它提出的只是在从列中获取值时进行转换(例如将某些日期转换为日期),但这不是我的意思。

I'm guessing it's something with Alter Table, and I looked that up on the MySQL dev page, but could not find what I was looking for.

我猜这是 Alter Table 的问题,我在 MySQL 开发页面上查了一下,但找不到我要找的东西。

回答by Ike Walker

Here's the real syntax. Make sure to set the nullability appropriately too:

这是真正的语法。确保也适当地设置可空性:

ALTER TABLE your_table
MODIFY COLUMN your_column DOUBLE NULL;

or

或者

ALTER TABLE your_table
MODIFY COLUMN your_column DOUBLE NOT NULL;

回答by eggyal

You're right that you need to use ALTER TABLE. The command will look something like this:

你是对的,你需要使用ALTER TABLE. 该命令将如下所示:

ALTER TABLE tablename MODIFY COLUMN columnname DOUBLE;