How should unix timestamps be stored in int columns?

前端 未结 1 1534
日久生厌
日久生厌 2020-12-08 01:39

I have a logging table that will contain millions of writes for statistical reasons. All the columns are int foreign keys. I am also going to add a timestamp column for each

相关标签:
1条回答
  • 2020-12-08 02:27

    Standard UNIX timestamps are a signed 32bit integer, which in MySQL is a regular "int" column. There's no way you could store 9,999,999,999, as that's way outside the representation range - the highest a 32bit int of any sort can go is 4,294,967,295. The highest a signed 32bit in goes is 2,147,483,647.

    If/when UNIX timestamps go to a 64bit data type, then you'll have to use a MySQL "bigint" to store them.

    As for int(10), the (10) portion is merely for display purposes. MySQL will still use a full 32bit internally to store the number, but only display 10 whenever you do a select on the table.

    0 讨论(0)
提交回复
热议问题