SQlite creating a database with a timestamp column and adding a value in

前端 未结 2 1779
悲&欢浪女
悲&欢浪女 2021-01-04 17:56

I am trying to create a database that called rawData. The db will hava a column for the id, a foreign user id (_id from another table), data and finally a timestamp.

2条回答
  •  长情又很酷
    2021-01-04 18:41

    The documentation says:

    SQLite does not have a storage class set aside for storing dates and/or times. Instead, the built-in Date And Time Functions of SQLite are capable of storing dates and times as TEXT, REAL, or INTEGER values:

    • TEXT as ISO8601 strings ("YYYY-MM-DD HH:MM:SS.SSS").
    • REAL as Julian day numbers, the number of days since noon in Greenwich on November 24, 4714 B.C. according to the proleptic Gregorian calendar.
    • INTEGER as Unix Time, the number of seconds since 1970-01-01 00:00:00 UTC.

    Applications can chose to store dates and times in any of these formats and freely convert between formats using the built-in date and time functions.

    If you need only seconds precision, use integers in Unix Time format. Otherwise, use floating-pointer numbers for fractional seconds.

提交回复
热议问题