{"id":71,"date":"2011-06-15T17:56:28","date_gmt":"2011-06-15T14:56:28","guid":{"rendered":"http:\/\/fatihacar.com\/blog\/?p=71"},"modified":"2011-06-15T18:04:22","modified_gmt":"2011-06-15T15:04:22","slug":"delete-row-from-table-which-have-constraint-column","status":"publish","type":"post","link":"http:\/\/www.fatihacar.com\/blog\/delete-row-from-table-which-have-constraint-column\/","title":{"rendered":"Delete row from table which have constraint column"},"content":{"rendered":"<p>You can use two method for this processing. You can either do disable constraint or use on delete cascade or on delete set null in table. <\/p>\n<p><strong>Method 1<\/strong><\/p>\n<blockquote><p>Table Name : employees<br \/>\nConstraints : primary_key_employee_id , foreign_key_department_id<\/p>\n<p>If you want to delete row from employees, you must disable foreign key constraint.<\/p>\n<p>ALTER TABLE employees DISABLE CONSTRAINT foreign_key_department_id;<\/p>\n<p>After, you can delete row from employees.If you want to make enable constraint, you can use bottom query.<\/p>\n<p>ALTER TABLE employees ENABLE CONSTRAINT foreign_key_department_id;\n<\/p><\/blockquote>\n<p><strong>Method 2<\/strong><\/p>\n<p>You must do table alter. You can use on delete cascade or on delete set null.<br \/>\nOn Delete Cascade : Deletes the dependent rows in the child table when a row in the parent table is deleted.<br \/>\nOn Delete Set Null : Converts the dependent foreign key values to null.<\/p>\n<blockquote><p>ALTER TABLE employees ON DELETE CASCADE;<br \/>\nALTER TABLE employees ON DELETE SET NULL;<\/p>\n<p>After, you can delete row from employees.<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>You can use two method for this processing. You can either do disable constraint or use on delete cascade or on delete set null in table. Method 1 Table Name : employees Constraints : primary_key_employee_id , foreign_key_department_id If you want to delete row from employees, you must disable foreign key constraint. ALTER TABLE employees DISABLE&#8230;<\/p>\n","protected":false},"author":37,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6],"tags":[90,91],"class_list":["post-71","post","type-post","status-publish","format-standard","hentry","category-oracle-sql","tag-oracle","tag-oracle-sql"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p39NFI-19","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts\/71","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/users\/37"}],"replies":[{"embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/comments?post=71"}],"version-history":[{"count":7,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts\/71\/revisions"}],"predecessor-version":[{"id":78,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts\/71\/revisions\/78"}],"wp:attachment":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/media?parent=71"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/categories?post=71"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/tags?post=71"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}