How to set default value for empty row for TEXT column?

I am using SQLite Manager.

I have a column called "MainContactName" and its structure is TEXT NOT NULL=0

By default, each row in a column has a "red background", which means NULL . How can I make this a "green background" and be an empty string?

+8
sqlite sqlite3
source share
1 answer

You can specify a default value for the column when creating the table. (It doesn't look like you can add a default value using the ALTER statement, so you have to recreate the table.)

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

Newlines that are inserted without the value specified for MainContactName will have an empty string for the MainContactName field. You can try to explicitly insert zeros in this field, but requests will explode due to the NOT NULL constraint.

+10
source share

All Articles