Created
March 13, 2018 19:33
-
-
Save mdamaceno/e7477a9dc3c4ff6c3239d65c9c092b36 to your computer and use it in GitHub Desktop.
Remove all constraints in a Firebird database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR ALTER PROCEDURE REMOVE_CONSTRAINTS AS | |
DECLARE VARIABLE stmt VARCHAR(255); | |
begin | |
BEGIN | |
FOR | |
select 'ALTER TABLE '||r.rdb$relation_name | |
||' DROP CONSTRAINT '||r.rdb$constraint_name||';' | |
from rdb$relation_constraints r | |
where (r.rdb$constraint_type='FOREIGN KEY') | |
into :stmt | |
DO | |
BEGIN | |
execute statement :stmt; | |
end | |
END | |
END | |
EXECUTE PROCEDURE REMOVE_CONSTRAINTS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment