日期时间与小日期时间

发布于 2024-08-13 08:32:19 字数 90 浏览 7 评论 0原文

如果我不关心少于秒,那么在 sql-server 2005 中存储我的日期时间值的推荐类型应该是什么,是 datetime 还是smalldatetime 还是其他?

If I don't care about less than seconds, what should be the recommended type to store my datetime values in sql-server 2005, is it datetime or smalldatetime or else?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

亢潮 2024-08-20 08:32:19

Smalldatetime 的分辨率低至一分钟,因此如果该分辨率适合您,则smalldatetime 小 50%(4 字节与 8 字节),因此是首选。

请参阅http://karaszi.com/the-ultimate-guide-to -the-datetime-datatypes 以获得良好的概述。

smalldatetime has a resolution down to one minute, so if that resoulution is OK for you, smalldatetime is 50% smaller (4 bytes vs. 8 bytes) so is preferred.

See http://karaszi.com/the-ultimate-guide-to-the-datetime-datatypes for a good overview.

可是我不能没有你 2024-08-20 08:32:19

如果您不确定,请使用日期时间 - 其他任何方式都是过早的优化。您可能会改变主意,认为将来需要几秒钟。

If you're unsure, use datetime - anything else is premature optimization. You might change your mind about needing seconds in the future.

薄凉少年不暖心 2024-08-20 08:32:19

如果你不关心秒数,1900 年之前或 2079 年之后的日期,smalldatetime 就可以了:)
否则你最好使用日期时间。

http://msdn.microsoft.com/en-us /library/aa258277(SQL.80).aspx

If you don't care about seconds, dates earlier than 1900 or later than 2079, smalldatetime will be fine :)
Otherwise you're better off with datetime.

http://msdn.microsoft.com/en-us/library/aa258277(SQL.80).aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文