nem.ec

Programming Information Security Recipes Personal Code Snippets

SQLite date column with default value

How to create a date column with a default value in a SQLite database

https://sqlite.org/lang_datefunc.html

Note: there is no “datetime” type, but as documented in the type affinities page, SQLite accepts it and converts the input to a numeric type internally.

CREATE TABLE "SAMPLE_TABLE" (
    "title" TEXT NOT NULL,
    "inserted_date" DATETIME DEFAULT CURRENT_TIMESTAMP
)