This means that if you delete a row in schemas.category, referenced by category_id in schemas.books, any such referencing row will also be deleted by ON DELETE CASCADE.Ĭlan_id integer REFERENCES shire.clans (id) ON DELETE CASCADEĭELETE FROM clans will CASCADE to hobbits by REFERENCES. CASCADE specifies that when a referenced row is deleted, row(s) referencing it should be automatically deleted as well. ![]() Restricting and cascading deletes are the two most common options. So in your case when user removes entries from categories table then rows will be deleted from books table. So it's all about what will happen when you delete rows from Parent table not from child table. ![]() The principal advantage to the cascading-deletes feature is that it allows you to reduce the quantity of SQL statements you need to perform delete actions. If you specify this option, later when you delete a row in the parent table, the database server also deletes any rows associated with that row (foreign keys) in a child table. If you do not specify cascading deletes, the default behaviour of the database server prevents you from deleting data in a table if other tables reference it. Issue 1460 typeorm/typeorm GitHub Fork 5.9k 31. ON DELETE CASCADE option is to specify whether you want rows deleted in a child table when corresponding rows are deleted in the parent table. You are saying in a opposite way, this is not that when you delete from child table then records will be deleted from parent table. A foreign key with a cascade delete means that if a record in the parent table is deleted, then the corresponding records in the child table will automatically be deleted. The PostgreSQL DELETE statement allows you to delete one or more rows from a table.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |