Created
January 5, 2011 16:16
-
-
Save iamvery/766524 to your computer and use it in GitHub Desktop.
Allows foreign key to be deferred during a transaction, but it will be applied immediately if not deferred.
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
ALTER TABLE "TableName" | |
ADD CONSTRAINT "ConstraintName" FOREIGN KEY ("columnName") | |
REFERENCES "AnotherTableName" ("anotherColumnName") MATCH SIMPLE | |
ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY IMMEDIATE; | |
-- I generally use the form "TableName_fk_constraintname" for foreign key constraint names (for reference) | |
-- This particular foreign key will cascade on update and delete, but those particular directives aren't required. (for reference) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment