Drop Unique Constraint on Table Column without Knowing the Constraint Name?

You can retrieve the constraint's name with: SELECT CONSTRAINT_NAME FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'xxx' AND CONSTRAINT_TYPE = 'U You can for instance create a stored procedure that executes the previous sql, stores its result in a variable and uses this variable in ALTER TABLE DROP CONSTRAINT EDIT: e.g. : BEGIN FOR r IN ( SELECT TABLE_NAME, CONSTRAINT_NAME FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'xxx' AND CONSTRAINT_TYPE = 'U') LOOP EXECUTE IMMEDIATE REPLACE(REPLACE( 'ALTER TABLE #TABLE# DROP CONSTRAINT #CON#' ,'#TABLE#',r. TABLE_NAME) ,'#CON#',r. CONSTRAINT_NAME); END LOOP; END.

You can retrieve the constraint's name with: SELECT CONSTRAINT_NAME FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'xxx' AND CONSTRAINT_TYPE = 'U' You can for instance create a stored procedure that executes the previous sql, stores its result in a variable and uses this variable in ALTER TABLE DROP CONSTRAINT EDIT: e.g. : BEGIN FOR r IN ( SELECT TABLE_NAME, CONSTRAINT_NAME FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'xxx' AND CONSTRAINT_TYPE = 'U') LOOP EXECUTE IMMEDIATE REPLACE(REPLACE( 'ALTER TABLE #TABLE# DROP CONSTRAINT #CON#' ,'#TABLE#',r. TABLE_NAME) ,'#CON#',r. CONSTRAINT_NAME); END LOOP; END.

Thanks, this worked nicely for my purposes. Though I can see that in some cases special care needs to be taken, like when you want to keep some unique constraints and drop others, since you can't simply zero in on specific columns involved in a constraint. – Stephen Swensen Oct 16 '10 at 15:56.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions