M melamoud Active Member Licensed User Longtime User May 24, 2013 #1 Hi guys, I'm trying to add a timestamp column and it wont let me, the code is simple Code: SQL1.ExecNonQuery("ALTER TABLE alerts ADD COLUMN added_on TIMESTAMP NOT NULL DEFAULT current_timestamp") the error is Code: 16:42:54 MNot:Failed to Upgrade DB to 0.92(92):(SQLiteException) android.database.sqlite.SQLiteException: Cannot add a column with non-constant default: ALTER TABLE alerts ADD COLUMN added_on TIMESTAMP NOT NULL DEFAULT current_timestamp is it not possible to add an automatic timestamp column ? any other trick ? thanks
Hi guys, I'm trying to add a timestamp column and it wont let me, the code is simple Code: SQL1.ExecNonQuery("ALTER TABLE alerts ADD COLUMN added_on TIMESTAMP NOT NULL DEFAULT current_timestamp") the error is Code: 16:42:54 MNot:Failed to Upgrade DB to 0.92(92):(SQLiteException) android.database.sqlite.SQLiteException: Cannot add a column with non-constant default: ALTER TABLE alerts ADD COLUMN added_on TIMESTAMP NOT NULL DEFAULT current_timestamp is it not possible to add an automatic timestamp column ? any other trick ? thanks
M melamoud Active Member Licensed User Longtime User May 24, 2013 #2 found this SQLite Query Language: ALTER TABLE which explain why it is not allowed , anyone can think of a work around (apart from copying the table to a temp table, drop it recreate it and copy back) - ouch! Upvote 0
found this SQLite Query Language: ALTER TABLE which explain why it is not allowed , anyone can think of a work around (apart from copying the table to a temp table, drop it recreate it and copy back) - ouch!
Erel B4X founder Staff member Licensed User Longtime User May 25, 2013 #3 You can set the current time yourself... Upvote 0