當前位置:首頁 » 存儲配置 » timestamp存儲

timestamp存儲

發布時間: 2023-03-11 13:50:32

⑴ datetime和timestamp的區別

datetime和timestamp是出現在MySQL和SqlServer資料庫中的。

MySQL中datetime和timestamp的區別:

(一)范圍不同。

datetime」 以'YYYY-MM-DD HH:MM:SS'格式檢索和顯示DATETIME值。支持的范圍為'1000-01-01 00:00:00'到'9999-12-31 23:59:59'TIMESTAMP值不能早於1970或晚於2037

(二)儲存不同。

1,TIMESTAMP

①4個位元組儲存(Time stamp value is stored in 4 bytes)

②值以UTC格式保存( it stores the number of milliseconds)

③時區轉化 ,存儲時對當前的時區進行轉換,檢索時再轉換回當前的時區。

2,datetime

①8個位元組儲存(8 bytes storage)

②實際格式儲存(Just stores what you have stored and retrieves the same thing which you have stored.)

③與時區無關(It has nothing to deal with the TIMEZONE and Conversion.)


註:TIMESTAMP列的顯示格式與datetime列相同。


SqlServer中datetime和timestamp在中用法區別基本都差不多。

datetime :

SqlServer中用兩個 4 位元組的整數內部存儲 datetime 數據類型的值。第一個 4 位元組存儲 base date(即 1900 年 1 月 1 日)之前或之後的天數。基礎日期是系統參考日期。不允許早於 1753 年 1 月 1 日的 datetime 值。另外一個 4 位元組存儲以午夜後毫秒數所代表的每天的時間。

註:smalldatetime 數據類型存儲日期和每天的時間,但精確度低於 datetime。SQL Server 將 smalldatetime 的值存儲為兩個 2 位元組的整數。第一個 2 位元組存儲 1900 年 1 月 1 日後的天數。另外一個 2 位元組存儲午夜後的分鍾數。日期范圍從1900 年 1 月 1 日到 2079 年 6 月 6 日,精確到分鍾。

timestamp:
timestamp 這種數據類型表現自動生成的二進制數,確保這些數在資料庫中是唯一的。timestamp 一般用作給錶行加版本戳的機制。存儲大小為 8 位元組。

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:587
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:882
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:574
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:761
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:678
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1006
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:251
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:108
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:799
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:706