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 - 如何更新小数列以允许更多位数?
基础教程推荐
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 在多列上分布任意行 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
