Skip to content

Instantly share code, notes, and snippets.

@ahmetonurslmz
Created August 22, 2020 12:56
Show Gist options
  • Save ahmetonurslmz/dc77c19f32a3b4faac5fb6a1d9e41f73 to your computer and use it in GitHub Desktop.
Save ahmetonurslmz/dc77c19f32a3b4faac5fb6a1d9e41f73 to your computer and use it in GitHub Desktop.
SQL - Attitudes types to adopted record when referenced record is deleted
  1. CASCADE: This enables us to remove its all adopted records when parent is deleted. For example, we have removed blog record, its adopted comment records will be deleted.

  2. RESTRICT: This enables us to prevent deletion of record when it has a adopted record at least.

  3. These enable us to set data that we want into relation column of adopted records that we will remove its parent.

  • SET NULL:
  • SET DEFAULT:
  • SET (...):
  1. NO ACTION: It does not anything. You should avoid choose this inside all of these choices.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment