Is there a way to create a table in sqlite3 that has a datetime column that defaults to 'now'?
The following statement returns a syntax error:
create table tbl1(id int primary key, dt datetime default datetime('now'));
Update: Here's the correct ddl courtesy of Sky Sanders:
create table tbl1(id int primary key, dt datetime default current_timestamp);
you can use the following query for using current date value in your table
CURRENT_TIMESTAMP
is a literal-value just like'mystring'
column-constraint:
literal-value:
Try this:
Background:
From http://www.sqlite.org/lang_createtable.html
The expression following
default
must be in parentheses. This form is useful if you want to perform date arithmetic using SQLite date and time functions or modifiers.