Set default value of an integer column SQLite

后端 未结 3 1519
逝去的感伤
逝去的感伤 2020-12-23 20:11

I am creating an SQLite database in android.

db.execSQL(\"CREATE TABLE \" + DATABASE_TABLE + \" (\" 
    + KEY_ROWID + \" INTEGER PRIMARY KEY AUTOINCREMENT,         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-23 20:56

    It happens that I'm just starting to learn coding and I needed something similar as you have just asked in SQLite (I´m using [SQLiteStudio] (3.1.1)).

    It happens that you must define the column's 'Constraint' as 'Not Null' then entering your desired definition using 'Default' 'Constraint' or it will not work (I don't know if this is an SQLite or the program requirment).

    Here is the code I used:

    CREATE TABLE  (
           INTEGER    UNIQUE
                                    PRIMARY KEY,
        TEXT       DEFAULT () 
                                    NOT NULL
    
    );
    

提交回复
热议问题