Skip to content

Instantly share code, notes, and snippets.

@mdamaceno
Created March 13, 2018 19:33
Show Gist options
  • Save mdamaceno/e7477a9dc3c4ff6c3239d65c9c092b36 to your computer and use it in GitHub Desktop.
Save mdamaceno/e7477a9dc3c4ff6c3239d65c9c092b36 to your computer and use it in GitHub Desktop.
Remove all constraints in a Firebird database
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