{"id":848,"date":"2012-07-26T07:57:21","date_gmt":"2012-07-26T07:57:21","guid":{"rendered":"http:\/\/www.withinweb.com\/info\/?p=848"},"modified":"2017-11-16T20:04:11","modified_gmt":"2017-11-16T20:04:11","slug":"sql-transactions-in-phpmyadmin","status":"publish","type":"post","link":"https:\/\/www.withinweb.com\/info\/sql-transactions-in-phpmyadmin\/","title":{"rendered":"SQL Transactions in phpMyAdmin"},"content":{"rendered":"<p>A transaction is a collection of SQL statements.\u00a0 So a task may, for example, consist of a number of update statements.\u00a0 If one of these should fail you may end up with some tables correctly updated but others not correctly updated particularly if one update has data from a previous update.<\/p>\n<p>To overcome this you define the SQL statements as a <strong>transaction<\/strong>. If one SQL statement should fail, you roll back the data to its initial state.\u00a0 Only when all the statements are successful will you commit the transaction.<\/p>\n<p>When you are entering SQL statements into mySQL you may use the begin \/ commit \u00a0\/ rollback transaction commands.<\/p>\n<p>So, say we are working with a <strong>person<\/strong> table and do an <strong>INSERT<\/strong> statement, we can either commit or rollback the transaction.<\/p>\n<p>The problem with\u00a0<strong>phpMyAdmin<\/strong> is that all the lines have to be in one command so it is not easy to demonstrate.<\/p>\n<p>However, we can demonstrate it using the following SQL statements and check the results for each.<\/p>\n<p>Copy the following lines in to the SQL editor in <strong>phpMyAdmin<\/strong>:<\/p>\n<p><strong>begin;<\/strong><br \/>\n<strong>INSERT INTO person (firstname, lastname) VALUES (&#8220;fred&#8221;, &#8220;blogs&#8221;);<br \/>\ncommit;<\/strong><\/p>\n<p>Examine the person table.\u00a0 We should see that a new record has been created.<\/p>\n<p>Now copy the following lines into the SQL editor in <strong>phpMyAdmin<\/strong>:<\/p>\n<p><strong>begin;<\/strong><br \/>\n<strong>INSERT INTO person (firstname, lastname) VALUES (&#8220;fred&#8221;, &#8220;blogs&#8221;);<br \/>\nrollback;<\/strong><\/p>\n<p>In this case the transaction has been rolled back and the record has not been created.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A transaction is a collection of SQL statements.\u00a0 So a task may, for example, consist of a number of update statements.\u00a0 If one of these should fail you may end up with some tables correctly updated but others not correctly<span class=\"ellipsis\">&hellip;<\/span><\/p>\n<div class=\"read-more\"><a href=\"https:\/\/www.withinweb.com\/info\/sql-transactions-in-phpmyadmin\/\">Read more <span class=\"screen-reader-text\">SQL Transactions in phpMyAdmin<\/span><span class=\"meta-nav\"> &#8250;<\/span><\/a><\/div>\n<p><!-- end of .read-more --><\/p>\n","protected":false},"author":40,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-848","post","type-post","status-publish","format-standard","hentry","category-sql_databases_and_queries"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SQL Transactions in phpMyAdmin - PHP Web Applications<\/title>\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.withinweb.com\/info\/sql-transactions-in-phpmyadmin\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Transactions in phpMyAdmin - PHP Web Applications\" \/>\n<meta property=\"og:description\" content=\"A transaction is a collection of SQL statements.\u00a0 So a task may, for example, consist of a number of update statements.\u00a0 If one of these should fail you may end up with some tables correctly updated but others not correctly&hellip;Read more SQL Transactions in phpMyAdmin &#8250;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.withinweb.com\/info\/sql-transactions-in-phpmyadmin\/\" \/>\n<meta property=\"og:site_name\" content=\"PHP Web Applications\" \/>\n<meta property=\"article:published_time\" content=\"2012-07-26T07:57:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-11-16T20:04:11+00:00\" \/>\n<meta name=\"author\" content=\"paulv\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"paulv\" \/>\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\":\"Article\",\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/sql-transactions-in-phpmyadmin\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/sql-transactions-in-phpmyadmin\\\/\"},\"author\":{\"name\":\"paulv\",\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/#\\\/schema\\\/person\\\/04da5531c302d55ffcd777fe81dbb93c\"},\"headline\":\"SQL Transactions in phpMyAdmin\",\"datePublished\":\"2012-07-26T07:57:21+00:00\",\"dateModified\":\"2017-11-16T20:04:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/sql-transactions-in-phpmyadmin\\\/\"},\"wordCount\":242,\"commentCount\":0,\"articleSection\":[\"SQL databases\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.withinweb.com\\\/info\\\/sql-transactions-in-phpmyadmin\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/sql-transactions-in-phpmyadmin\\\/\",\"url\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/sql-transactions-in-phpmyadmin\\\/\",\"name\":\"SQL Transactions in phpMyAdmin - PHP Web Applications\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/#website\"},\"datePublished\":\"2012-07-26T07:57:21+00:00\",\"dateModified\":\"2017-11-16T20:04:11+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/#\\\/schema\\\/person\\\/04da5531c302d55ffcd777fe81dbb93c\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/sql-transactions-in-phpmyadmin\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.withinweb.com\\\/info\\\/sql-transactions-in-phpmyadmin\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/sql-transactions-in-phpmyadmin\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Transactions in phpMyAdmin\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/#website\",\"url\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/\",\"name\":\"PHP Web Applications\",\"description\":\"Information and support for products of WithinWeb.com\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/#\\\/schema\\\/person\\\/04da5531c302d55ffcd777fe81dbb93c\",\"name\":\"paulv\",\"url\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/author\\\/paulv\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQL Transactions in phpMyAdmin - PHP Web Applications","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.withinweb.com\/info\/sql-transactions-in-phpmyadmin\/","og_locale":"en_US","og_type":"article","og_title":"SQL Transactions in phpMyAdmin - PHP Web Applications","og_description":"A transaction is a collection of SQL statements.\u00a0 So a task may, for example, consist of a number of update statements.\u00a0 If one of these should fail you may end up with some tables correctly updated but others not correctly&hellip;Read more SQL Transactions in phpMyAdmin &#8250;","og_url":"https:\/\/www.withinweb.com\/info\/sql-transactions-in-phpmyadmin\/","og_site_name":"PHP Web Applications","article_published_time":"2012-07-26T07:57:21+00:00","article_modified_time":"2017-11-16T20:04:11+00:00","author":"paulv","twitter_card":"summary_large_image","twitter_misc":{"Written by":"paulv","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.withinweb.com\/info\/sql-transactions-in-phpmyadmin\/#article","isPartOf":{"@id":"https:\/\/www.withinweb.com\/info\/sql-transactions-in-phpmyadmin\/"},"author":{"name":"paulv","@id":"https:\/\/www.withinweb.com\/info\/#\/schema\/person\/04da5531c302d55ffcd777fe81dbb93c"},"headline":"SQL Transactions in phpMyAdmin","datePublished":"2012-07-26T07:57:21+00:00","dateModified":"2017-11-16T20:04:11+00:00","mainEntityOfPage":{"@id":"https:\/\/www.withinweb.com\/info\/sql-transactions-in-phpmyadmin\/"},"wordCount":242,"commentCount":0,"articleSection":["SQL databases"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.withinweb.com\/info\/sql-transactions-in-phpmyadmin\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.withinweb.com\/info\/sql-transactions-in-phpmyadmin\/","url":"https:\/\/www.withinweb.com\/info\/sql-transactions-in-phpmyadmin\/","name":"SQL Transactions in phpMyAdmin - PHP Web Applications","isPartOf":{"@id":"https:\/\/www.withinweb.com\/info\/#website"},"datePublished":"2012-07-26T07:57:21+00:00","dateModified":"2017-11-16T20:04:11+00:00","author":{"@id":"https:\/\/www.withinweb.com\/info\/#\/schema\/person\/04da5531c302d55ffcd777fe81dbb93c"},"breadcrumb":{"@id":"https:\/\/www.withinweb.com\/info\/sql-transactions-in-phpmyadmin\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.withinweb.com\/info\/sql-transactions-in-phpmyadmin\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.withinweb.com\/info\/sql-transactions-in-phpmyadmin\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.withinweb.com\/info\/"},{"@type":"ListItem","position":2,"name":"SQL Transactions in phpMyAdmin"}]},{"@type":"WebSite","@id":"https:\/\/www.withinweb.com\/info\/#website","url":"https:\/\/www.withinweb.com\/info\/","name":"PHP Web Applications","description":"Information and support for products of WithinWeb.com","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.withinweb.com\/info\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.withinweb.com\/info\/#\/schema\/person\/04da5531c302d55ffcd777fe81dbb93c","name":"paulv","url":"https:\/\/www.withinweb.com\/info\/author\/paulv\/"}]}},"_links":{"self":[{"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/posts\/848","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/users\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/comments?post=848"}],"version-history":[{"count":5,"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/posts\/848\/revisions"}],"predecessor-version":[{"id":1299,"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/posts\/848\/revisions\/1299"}],"wp:attachment":[{"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/media?parent=848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/categories?post=848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/tags?post=848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}