Is there a way to drop a PK from a table by selecting the name into a variable from all_constraints, I need to run this script on multi databases that the actual name of the PK could possibly be different.

I can get the name in a variable but don't know how to execute,
since an ALTER TALBE is not valid in the execute section.


DECLARE
PKNAME CHAR(50);
CMD CHAR(300);

BEGIN
SELECT CONSTRAINT_NAME INTO PKNAME FROM ALL_CONSTRAINTS WHERE TABLE_NAME = 'APQUICKD' AND CONSTRAINT_TYPE LIKE 'U';

----can I build and execute a string here????

END;

Look into the 'execute immediate' command. You can use it to drop your constraint using the value in PKNAME.

Thanks for the suggestion, I was able figure it out.
Not much fun converting MS SQL scripts to PL/SQL scripts,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.