如何在mysql中使用alter添加列? [英] How to add column using alter in mysql?

查看:111
本文介绍了如何在mysql中使用alter添加列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过在alter上输入值来添加该列? 作为示例,我想添加 tempID 的列,每一行的值均为"3"

How to add the column using alter by inputting the values on it? As the example, I want to add tempID's column which has value "3" on every row

也许是这样

ALTER TABLE NAMEYOURTABLE
   ADD COLUMN last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

,但是上面的代码仅用于时间戳,不适用于整数值.预先感谢

but the code above is only for the timestamp, not for integer values. Thanks in advance

推荐答案

您应该查看对于您而言,它类似于

ALTER TABLE NAMEYOURTABLE ADD COLUMN tempID int NULL DEFAULT 3;

这篇关于如何在mysql中使用alter添加列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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