Skip to content

Instantly share code, notes, and snippets.

@sebastianwebber
Created June 27, 2015 23:01
Show Gist options
  • Select an option

  • Save sebastianwebber/77b2567cea5ad4384f39 to your computer and use it in GitHub Desktop.

Select an option

Save sebastianwebber/77b2567cea5ad4384f39 to your computer and use it in GitHub Desktop.
Trabalhando com Constraints - PostgreSQL
SELECT
'ALTER TABLE ' ||
schema.nspname || '.' || class.relname
|| ' DROP CONSTRAINT IF EXISTS ' ||
cons.conname || ';'
FROM pg_constraint AS cons
JOIN pg_class AS class on class.oid = cons.conrelid
JOIN pg_namespace AS schema on schema.oid = cons.connamespace
WHERE schema.nspname = 'schema'
AND class.relname = 'tabela';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment