我需要在Sybase中删除表上的所有默认列级约束。Sybase - 默认约束条件
我没有任何想法如何做到这一点,我曾试图用如下以下禁用的约束:
ALTER TABLE Employee NOCHECK CONSTRAINT ALL
上面甚至不工作,给出了如下错误:
Error (156) Incorrect syntax near the keyword 'CONSTRAINT'
而且,我已经尝试了一些自定义的存储过程,用sys表,但就是不符合语法的Sybase,它的工作原理的SQL服务器上,如下图所示:
declare @sql varchar(1024)
declare curs cursor for
select 'ALTER TABLE '+tab.name+' DROP CONSTRAINT '+cons.name
from sysobjects cons,sysobjects tab
where cons.type in ('D')
and cons.parent_object_id=tab.object_id and tab.type='U'
order by cons.type
open curs
fetch next from curs into @sql
while (@@fetch_status = 0)
begin
exec(@sql)
fetch next from curs into @sql
end
close curs
deallocate curs
有人可以解决这个谜语吗?