Posts

Showing posts from August, 2019

How do I disable FOREIGN KEY checking for the time of database schema migration?

How do I disable  FOREIGN KEY  checking for the time of database schema migration? Currently I found engine-based commands like: PostgreSQL:  SET CONSTRAINTS ALL DEFERRED; MSSQL:  EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"; MySQL:  SET FOREIGN_KEY_CHECKS = 0; HSQLDB:  SET REFERENTIAL_INTEGRITY FALSE; DB2:  SET INTEGRITY FOR table OFF; SQLite 3.7.16:  PRAGMA foreign_keys = false; Oracle 11g seems to have no such command at all Syntax significantly differ, in case of MSSQL I'm unable to recover previously disabled constraints (if any).