0 votes
1 view
in SQL by (20.3k points)

Is it possible in a SQLite database to create a table that has a timestamp column that defaults to DATETIME('now')?

Like this:

CREATE TABLE test (

    id INTEGER PRIMARY KEY AUTOINCREMENT, 

    t TIMESTAMP DEFAULT DATETIME('now')

);

This gives an error... How to resolve?

1 Answer

0 votes
by (40.4k points)

Try the code given below:

CREATE TABLE test (

  id INTEGER PRIMARY KEY AUTOINCREMENT,

  t TIMESTAMP

  DEFAULT CURRENT_TIMESTAMP

);

Related questions

0 votes
1 answer
0 votes
1 answer
asked Dec 12, 2020 in SQL by Appu (6.1k points)
0 votes
1 answer
0 votes
1 answer
asked Jan 5 in SQL by Appu (6.1k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...