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

后端 未结 1 1668
攒了一身酷
攒了一身酷 2020-12-31 10:56

I am using SQLite Manager.

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

By default, every row in the column ha

相关标签:
1条回答
  • 2020-12-31 11:19

    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 '')
    

    New rows that are inserted without a value specified for MainContactName will have an empty string for the MainContactName field. You could try to explicitly insert nulls into that field, but the queries would blow up due to the NOT NULL constraint.

    0 讨论(0)
提交回复
热议问题