Altering SQLite column type and adding PK constraint

前端 未结 3 1795
隐瞒了意图╮
隐瞒了意图╮ 2021-02-05 19:32

How to change the type of a column in a SQLite table?

I\'ve got:

    CREATE TABLE table(
        id INTEGER,
        salt TEXT NOT NULL UNIQUE,
        s         


        
3条回答
  •  梦毁少年i
    2021-02-05 20:00

    In this case you can make salt to nullable and remove unique constraint. Also If id column does not contain any null or duplicate values you can safely make it primary key using sql server management studio. below is the screen shot. hope it makes it clearer: alt text http://img265.imageshack.us/img265/7418/91573473.png

    or use following sql:

    alter table  modify salt text null
    alter table  drop constraint 
    alter table  modify id int not null
    alter table  add constraint pkd primary key (id)
    

    提交回复
    热议问题