MySQL - How do I update the decimal column to allow more digits?(MySQL - 如何更新小数列以允许更多位数?)
问题描述
我是 MySQL 的初学者,我不小心创建了一个表,其中包含一个名为
I'm a beginner in MySQL, and I accidentally created a table with a column named
(price decimal(2,2));
它需要是 decimal(4,2)
以允许 4 位数字.既然我已经创建了它,那么将该十进制值更新为 decimal(4,2)
的最简单方法是什么?还是我需要完全删除该列,然后用正确的数字重新创建它?
It needs to be decimal(4,2)
to allow 4 digits. Since I've already created it, what is the easiest way to update that decimal value to decimal(4,2)
? Or do I need to drop that column completely, and re-create it with the correct numbers?
推荐答案
ALTER TABLE mytable MODIFY COLUMN mycolumn newtype
示例:
ALTER TABLE YourTableNameHere MODIFY COLUMN YourColumnNameHere decimal(4,2)
这篇关于MySQL - 如何更新小数列以允许更多位数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MySQL - 如何更新小数列以允许更多位数?


基础教程推荐
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01