problem with drop constraints
Posted in 2000
Topics: General Discussion
Hi !
Is there any way that i can drop a constraints dynamically ?
like this ?
alter table sam_user
( drop constraints ( select constrname from sysconstraints
where tabid = (
select tabid from systables
where tabname = "sam_user")
and constrtype = "R"
and idxname = (
select idxname from sysindexes
where tabid = (select tabid from systables where tabname = "sam_user")
and idxtype = "D"
and part1 = 5)
)
)
i have to write specifically "drop constraints r1323_12272"
TIA,
nayan jain !
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"For most gulls, it is not flying that matters, but eating
For this gull,though, it was not eating that mattered but flight."
-- Jonathan Livingston Seagull
if you wanted - you could disable the constraint
as well, then re-enable it later.
set constraints for <tablename> disabled;
this would work if no other objects are referencing
the constrained field(s).
after you set the constraint disabled, you can record
the violations to the integrity of the table and continue
processing with a start violations table for <tablename>.
on the other hand, when you created the table you could have
a semantic pattern for your 'named' constraints,
and put that in your sql when you needed it,
or disable the constraint when you created the object
in the first place.
and btw, why do you want to do this?
nayan jain wrote:
> Hi !
>
> Is there any way that i can drop a constraints dynamically ?
>
> like this ?
>
> alter table sam_user
> ( drop constraints ( select constrname from sysconstraints
> where tabid = (
> select tabid from systables
> where tabname = "sam_user")
> and constrtype = "R"
> and idxname = (
> select idxname from sysindexes
> where tabid = (select tabid from systables where tabname = "sam_user")
> and idxtype = "D"
> and part1 = 5)
> )
> )>
> i have to write specifically "drop constraints r1323_12272"
>
> TIA,
> nayan jain !
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> "For most gulls, it is not flying that matters, but eating
> For this gull,though, it was not eating that mattered but flight."
> -- Jonathan Livingston Seagull