亚洲免费乱码视频,日韩 欧美 国产 动漫 一区,97在线观看免费视频播国产,中文字幕亚洲图片

      1. <legend id="ppnor"></legend>

      2. 
        
        <sup id="ppnor"><input id="ppnor"></input></sup>
        <s id="ppnor"></s>

        sql server刪除外鍵約束

        字號(hào):


            x先找出約束名字
            然后刪除它
            我給個(gè)例子
            --測(cè)試環(huán)境
            --主表
            create table test1(id int primary key not null,value int)
            insert test1 select 1,2
            go
            --從表
            create table test2(id int references test1(id),value int)
            go
            --第一步:找出test2表上的外鍵約束名字
            --2000
            exec sp_helpconstraint 'test2'
            --可以在constraint_name 屬性中找到外鍵約束名字
            --2005
            select name
            from sys.foreign_key_columns f join sys.objects o on f.constraint_object_id=o.object_id
            where f.parent_object_id=object_id('test2')
            /*
            name
            ---------------------------------
            FK__test2__id__08EA5793*/
            --第二步:刪除外鍵約束
            alter table test2 drop constraint FK__test2__id__08EA5793
            --第三步:檢查表上是否還有外鍵約束
            --只要使用第一步里面的查找語(yǔ)句即可
            alter table mytable drop index mdl_tag_use_ix;//mdl_tag_use_ix是上表查出的索引名,key_name