MySQL - 如何更新小数列以允许更多位数? [英] MySQL - How do I update the decimal column to allow more digits?

查看:32
本文介绍了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 - 如何更新小数列以允许更多位数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆