How to set a default value to a TEXT column in Sqlite? How to set a default value to a TEXT column in Sqlite? sqlite sqlite

How to set a default value to a TEXT column in Sqlite?


You can specify a default value for the column when you create the table. (It doesn't appear as though you can add a default using an ALTER statement, so you'll have to recreate your table.)

CREATE TABLE your_table_name(MainContactName TEXT NOT NULL DEFAULT '')

For Example,

CREATE TABLE book(_id INTEGER PRIMARY KEY AUTOINCREMENT,book TEXT DEFAULT "abc");

now see that , default value is set to "abc"

Check sqllite documentation.


To alter table,

sqlitedbInstance.execSQL("alter table myTable add column Address TEXT DEFAULT 'ABC' ");