MySQL:使用DATETIME作为主键 [英] MySQL: Using DATETIME as primary key
本文介绍了MySQL:使用DATETIME作为主键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用DATETIME对象作为主键是否有意义?
谢谢,
解决方案
不,因为它不能保证是唯一的。坚持使用BIGINT。你可以在DateTime上放置一个很好的索引来进行查询,并且它会很好。
My database will be storing a large number of data points, so I am using an unsigned BIGINT as the primary key.
Would it ever make sense to use a DATETIME object as the primary key?
Thanks,
解决方案
No because it can't be guaranteed to be unique. Stick with BIGINT. You can put a nice index on the DateTime for querying and it will be good enough.
这篇关于MySQL:使用DATETIME作为主键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文