且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL Server数据库设计日期时间

更新时间:2023-01-20 07:51:50

答案是: 不! (用于将日期分成另一个表格和另一个表格的时间!)



使用一个表格并正确数据类型 [ ^ ](datetime,datetimeoffset)。


使用 datetime或datetime2 [ ^ ]您可以在datetime列上创建索引以提高性能。

http://explainextended.com/2009/11/11/sql-server-clustered-index-and-ordering/ [ ^ ]

Hi everyone, I need some help here
Background:

My DB need to store YYYY-MM-DD and HH:MM:SS data generated from a Machine. Data will be inserted every few minutes, every day will have Thousands of records

Questions:

Should I separate Date column into another table with DateID and DateName??

What about time? HH:MM:SS, should it be another table or just a column???

How about query performance?? Should I index Date and Time Column with FK????

What's the best pratices for Date and Time stamp??

Thanks for your help in advance.

The answer is: No! (for separating Date into another table and Time for another table!)

Use one table and proper data type[^] (datetime, datetimeoffset).


use datetime or datetime2 [^] and you can create index on datetime column to increase the performance.
http://explainextended.com/2009/11/11/sql-server-clustered-index-and-ordering/[^]