参考联机丛书的alter table!

解决方案 »

  1.   

    --把B列设为外键
    外键是要依赖于另一表的主键,所以你还要提供这个外键与那个表的主键建立关系--让C列成为标识列种子是1,增量是1
    不能用sql语句直接修改某字段为标识列,你应该在建表时设置
    或者是删除C列重建:
    alter table 你的表 drop column C
    alter table 你的表 add C int identity(1,1)
      

  2.   

    --其他的--把A列设为主键
    alter table 你的表 add constraint PK_主键名 primary key(A)--为D列添加检查约束使D列的值不能小于50,同时让D列不能为空,
    alter table 你的表 add constraint CHK_约束名 check(D is not null and D>=50)--给E列加一个默认直‘VIVID’
    alter table 你的表 add constraint DF_约束名 default 'VIVID' for E--为F列添加唯一约束。
    alter table 你的表 add constraint UQ_约束名 unique(F)