如何将日期列添加到具有当前日期作为默认值的表中?

Sta*_*tas 7 sqlite

我在哪里可以看到SQLite表创建后会有哪些默认列?我需要一个datetime列,当数据添加到表时,它具有默认的time值.

现在我正在尝试:

ALTER TABLE recipes ADD COLUMN timestamp DATE DEFAULT (datetime('now','localtime'));
Run Code Online (Sandbox Code Playgroud)

我收到以下消息:

SQLiteManager: Likely SQL syntax error: ALTER TABLE recipes ADD COLUMN timestamp DATE DEFAULT (datetime('now','localtime')); [ Cannot add a column with non-constant default ]
Exception Name: NS_ERROR_FAILURE
 Exception Message: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE)         [mozIStorageConnection.createStatement]
Run Code Online (Sandbox Code Playgroud)

dev*_*and 12

使用create table而不是更改表.如果里面有值,你就会遇到这种问题.看到

http://sqlite.1065341.n5.nabble.com/Can-t-insert-timestamp-field-with-value-CURRENT-TIME-td42729.html

祝一切顺利