How do DATETIME values work in SQLite?

后端 未结 5 708
孤独总比滥情好
孤独总比滥情好 2020-11-27 13:22

I’m creating Android apps and need to save date/time of the creation record. The SQLite docs say, however, \"SQLite does not have a storage class set aside for storing dates

5条回答
  •  佛祖请我去吃肉
    2020-11-27 13:34

    One of the powerful features of SQLite is allowing you to choose the storage type. Advantages/disadvantages of each of the three different possibilites:

    • ISO8601 string

      • String comparison gives valid results
      • Stores fraction seconds, up to three decimal digits
      • Needs more storage space
      • You will directly see its value when using a database browser
      • Need for parsing for other uses
      • "default current_timestamp" column modifier will store using this format
    • Real number

      • High precision regarding fraction seconds
      • Longest time range
    • Integer number

      • Lowest storage space
      • Quick operations
      • Small time range
      • Possible year 2038 problem

    If you need to compare different types or export to an external application, you're free to use SQLite's own datetime conversion functions as needed.

提交回复
热议问题