【发布时间】:2011-05-25 05:52:06
【问题描述】:
我需要在 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
谁能解开这个谜题..
【问题讨论】:
标签: sybase