當前位置:首頁 » 存儲配置 » 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 位元組。

熱點內容
手機版編程軟體 發布:2025-07-07 22:57:22 瀏覽:120
linux下執行sh腳本 發布:2025-07-07 22:49:00 瀏覽:127
雲盤怎麼存儲資料 發布:2025-07-07 22:49:00 瀏覽:914
禁止別人綁定自己伺服器ip 發布:2025-07-07 22:45:58 瀏覽:55
qqandroid版 發布:2025-07-07 22:29:59 瀏覽:41
python解壓gz 發布:2025-07-07 22:03:19 瀏覽:622
安卓俄羅斯方塊源碼 發布:2025-07-07 21:56:11 瀏覽:475
安卓手機之王是哪個手機 發布:2025-07-07 21:44:30 瀏覽:615
安卓照片存儲位置 發布:2025-07-07 21:31:58 瀏覽:966
kingcmsphp 發布:2025-07-07 21:31:49 瀏覽:393