问题描述
我想将一百万行以上的表中的列数据类型从TIMESTAMP转换为DATETIME.
I want to convert a column data type from TIMESTAMP to DATETIME in a table with more than one million of lines.
有可能吗?慢吗?我会丢失旧信息还是MySQL可以自动将其转换?我可以做一个变更表还是做一些不同的事情?
Is it possible? Is it slow? Will I loose the old information or MySQL can convert this automatically? Can I just do an alter table or may I do something different?
推荐答案
有可能吗? -是的
慢吗? -可能要花点时间.
Is it slow? - It will probably take a while.
TIMESTAMP和DATETIME之间的区别在这里稍作解释:我应该使用字段"datetime"还是"timestamp" '?
The difference between TIMESTAMP and DATETIME is explained a bit over here: Should I use field 'datetime' or 'timestamp'?
通常,除非您真的没有其他选择,否则我认为更改类型不是一件明智的事情.您将丢失实际上要保留的数据,或者将创建需要存在的数据.这些数据很可能不会成为您所需要的.
Generally, I don't think changing a type is a smart thing to do unless you are really left without any other options. You will lose data that you actually want to keep or data that needs to exists will be created. This data is most likely not going to be what you need it to be.
这篇关于在MySQL中将列类型TIMESTAMP更改为DATETIME时会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!