<br />
<b>Warning</b>:  Undefined array key "global_protection_id" in <b>/home/wikitechy/public_html/interview-questions/wp-content/plugins/content-protector/inc/class-ps-rest-handler.php</b> on line <b>51</b><br />
{"id":4427,"date":"2022-06-03T11:42:11","date_gmt":"2022-06-03T11:42:11","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=4427"},"modified":"2022-06-03T11:42:11","modified_gmt":"2022-06-03T11:42:11","slug":"difference-between-delete-and-truncate","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/dbms\/difference-between-delete-and-truncate\/","title":{"rendered":"Difference between Delete and Truncate"},"content":{"rendered":"<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-4428 aligncenter\" src=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/05\/what-is-the-difference-between-delete-and-truncate.jpg\" alt=\"\" width=\"558\" height=\"441\" srcset=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/05\/what-is-the-difference-between-delete-and-truncate.jpg 558w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/05\/what-is-the-difference-between-delete-and-truncate-300x237.jpg 300w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/05\/what-is-the-difference-between-delete-and-truncate-390x308.jpg 390w\" sizes=\"(max-width: 558px) 100vw, 558px\" \/><\/p>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"312\">\n<h4 id=\"delete\" style=\"text-align: center;\"><strong>Delete<\/strong><\/h4>\n<\/td>\n<td width=\"312\">\n<h4 id=\"truncate\" style=\"text-align: center;\"><strong>Truncate<\/strong><\/h4>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">Used to delete rows from a table based on the condition provided on the where clause.<\/td>\n<td width=\"312\">Used to delete the entire data from rows from the table. Similar to delete command with no where clause<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">\u00a0Delete commands deletes only the rows that are mentioned in where clause.<\/p>\n<p>&nbsp;<\/td>\n<td width=\"312\">Truncate command deletes complete row from\u00a0 a table.<\/p>\n<p>&nbsp;<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">We can roll back the delete commands.<\/p>\n<p>&nbsp;<\/td>\n<td width=\"312\">We cannot roll back the truncate commands.<\/p>\n<p>&nbsp;<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">Delete command is very slow because it maintains a log<\/p>\n<p>&nbsp;<\/td>\n<td width=\"312\">That&#8217;s why it is fast. This command is very fast as it does not maintain any log<\/p>\n<p>&nbsp;<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">It uses row lock when performing delete function<\/p>\n<p>&nbsp;<\/td>\n<td width=\"312\">Truncate command uses table log while performing the truncate function<\/p>\n<p>&nbsp;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Delete Truncate Used to delete rows from a table based on the condition provided on the where clause. Used to delete the entire data from rows from the table. Similar to delete command with no where clause \u00a0Delete commands deletes only the rows that are mentioned in where clause. &nbsp; Truncate command deletes complete [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"passster_activate_protection":false,"passster_protect_child_pages":"","passster_protection_type":"password","passster_password":"","passster_activate_overwrite_defaults":"","passster_headline":"","passster_instruction":"","passster_placeholder":"","passster_button":"","passster_id":"","passster_activate_misc_settings":"","passster_redirect_url":"","passster_hide":"no","passster_area_shortcode":"","gtb_hide_title":false,"gtb_wrap_title":false,"gtb_class_title":"","gtb_remove_headerfooter":false,"footnotes":""},"categories":[7157],"tags":[17460,17458,17456,17452,17462,17463,17461,17455,17464,17457,17453,17459],"class_list":["post-4427","post","type-post","status-publish","format-standard","hentry","category-dbms","tag-delete-vs-truncate-vs-drop-in-sql","tag-difference-between-delete-and-drop","tag-difference-between-delete-and-truncate","tag-difference-between-delete-and-truncate-command","tag-difference-between-delete-and-truncate-in-oracle","tag-difference-between-delete-and-truncate-in-sql-query","tag-difference-between-delete-drop-and-truncate","tag-difference-between-truncate-and-delete-in-sql","tag-differences-between-delete-and-truncate-in-sql-server","tag-truncate-command-in-sql","tag-what-is-the-main-difference-between-delete-and-truncate-in-sql","tag-why-truncate-is-faster-than-delete"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Difference between Delete and Truncate - Delete vs Truncate Command<\/title>\n<meta name=\"description\" content=\"Difference between Delete and Truncate - Used to delete rows from a table based on the condition provided on the where clause.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wikitechy.com\/interview-questions\/dbms\/difference-between-delete-and-truncate\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Difference between Delete and Truncate - Delete vs Truncate Command\" \/>\n<meta property=\"og:description\" content=\"Difference between Delete and Truncate - Used to delete rows from a table based on the condition provided on the where clause.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/dbms\/difference-between-delete-and-truncate\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2022-06-03T11:42:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/05\/what-is-the-difference-between-delete-and-truncate.jpg\" \/>\n<meta name=\"author\" content=\"webmaster\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webmaster\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/dbms\/difference-between-delete-and-truncate\/\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/dbms\/difference-between-delete-and-truncate\/\",\"name\":\"Difference between Delete and Truncate - Delete vs Truncate Command\",\"isPartOf\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/dbms\/difference-between-delete-and-truncate\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/dbms\/difference-between-delete-and-truncate\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/05\/what-is-the-difference-between-delete-and-truncate.jpg\",\"datePublished\":\"2022-06-03T11:42:11+00:00\",\"dateModified\":\"2022-06-03T11:42:11+00:00\",\"author\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\"},\"description\":\"Difference between Delete and Truncate - Used to delete rows from a table based on the condition provided on the where clause.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wikitechy.com\/interview-questions\/dbms\/difference-between-delete-and-truncate\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/dbms\/difference-between-delete-and-truncate\/#primaryimage\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/05\/what-is-the-difference-between-delete-and-truncate.jpg\",\"contentUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/05\/what-is-the-difference-between-delete-and-truncate.jpg\",\"width\":558,\"height\":441},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\",\"name\":\"webmaster\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"caption\":\"webmaster\"},\"sameAs\":[\"https:\/\/www.wikitechy.com\/interview-questions\"],\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Difference between Delete and Truncate - Delete vs Truncate Command","description":"Difference between Delete and Truncate - Used to delete rows from a table based on the condition provided on the where clause.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wikitechy.com\/interview-questions\/dbms\/difference-between-delete-and-truncate\/","og_locale":"en_US","og_type":"article","og_title":"Difference between Delete and Truncate - Delete vs Truncate Command","og_description":"Difference between Delete and Truncate - Used to delete rows from a table based on the condition provided on the where clause.","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/dbms\/difference-between-delete-and-truncate\/","og_site_name":"Wikitechy","article_published_time":"2022-06-03T11:42:11+00:00","og_image":[{"url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/05\/what-is-the-difference-between-delete-and-truncate.jpg"}],"author":"webmaster","twitter_card":"summary_large_image","twitter_misc":{"Written by":"webmaster","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/dbms\/difference-between-delete-and-truncate\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/dbms\/difference-between-delete-and-truncate\/","name":"Difference between Delete and Truncate - Delete vs Truncate Command","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/dbms\/difference-between-delete-and-truncate\/#primaryimage"},"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/dbms\/difference-between-delete-and-truncate\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/05\/what-is-the-difference-between-delete-and-truncate.jpg","datePublished":"2022-06-03T11:42:11+00:00","dateModified":"2022-06-03T11:42:11+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4"},"description":"Difference between Delete and Truncate - Used to delete rows from a table based on the condition provided on the where clause.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/dbms\/difference-between-delete-and-truncate\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/dbms\/difference-between-delete-and-truncate\/#primaryimage","url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/05\/what-is-the-difference-between-delete-and-truncate.jpg","contentUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/05\/what-is-the-difference-between-delete-and-truncate.jpg","width":558,"height":441},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4","name":"webmaster","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","caption":"webmaster"},"sameAs":["https:\/\/www.wikitechy.com\/interview-questions"],"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4427","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=4427"}],"version-history":[{"count":2,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4427\/revisions"}],"predecessor-version":[{"id":4452,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4427\/revisions\/4452"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=4427"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=4427"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=4427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}