请问怎样用SQL关闭数据库索引,怎样用SQL关闭默认值?急!!!!

解决方案 »

  1.   

    因为要用SQL改变字段类型,但是有索引和默认值的不能改变,所以想关闭触发器和约束是能关闭的,这个就不知道了
      

  2.   

    关闭触发器和约束是能关闭的
    --------------------
    ALTER TABLE trig_example DISABLE TRIGGER trig1--关闭触发器
    ALTER TABLE cnst_example NOCHECK CONSTRAINT salary_cap --关闭约束
      

  3.   

    //ALTER TABLE cnst_example NOCHECK CONSTRAINT salary_cap --关闭约束
    只适用于Check约束。关闭默认值
    ALTER TABLE YourTable Drop Constraint DF_YourTable_YourColumn 
    (DF: Default 通常系统生成该约束名)
    启用默认值(重设)
    ALTER TABLE YourTable Add Constraint DF_YourTable_YourColumn Default YourDefaultValue For YourColumn 关闭索引
    Alter Index YourIndex On YourTable Disable
    启用索引
    Alter Index YourIndex On YourTable Rebuild 以上带Your的是需要根据你的实际数据库情况填写的
    如: YourTable指你的表名