Answers for "keep data in foreign key deletion"

SQL
5

drop foreign key

ALTER TABLE table_name
DROP CONSTRAINT fk_name;
Posted by: Guest on June-04-2020
0

foreign key on delete arguments

class Artist(models.Model):
    name = models.CharField(max_length=10)

class Album(models.Model):
    artist = models.ForeignKey(Artist, on_delete=models.CASCADE)

class Song(models.Model):
    artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
    album = models.ForeignKey(Album, on_delete=models.RESTRICT)
Posted by: Guest on June-19-2021

Code answers related to "keep data in foreign key deletion"

Code answers related to "SQL"

Browse Popular Code Answers by Language