<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>FOREIGN_KEY_CHECKS &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/foreign_key_checks/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Thu, 16 Nov 2017 13:20:36 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>MySQL: How to TRUNCATE all Tables of a Database?</title>
		<link>https://www.dbrnd.com/2016/09/mysql-how-to-truncate-all-tables-of-a-database/</link>
					<comments>https://www.dbrnd.com/2016/09/mysql-how-to-truncate-all-tables-of-a-database/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 29 Sep 2016 16:16:57 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[FOREIGN_KEY_CHECKS]]></category>
		<category><![CDATA[information_schema.tables]]></category>
		<category><![CDATA[MySQL Command]]></category>
		<category><![CDATA[MySQL Database Administrator]]></category>
		<category><![CDATA[MySQL Database Designing]]></category>
		<category><![CDATA[MySQL Database Programming]]></category>
		<category><![CDATA[MySQL Error]]></category>
		<category><![CDATA[MySQL Performance Tunning]]></category>
		<category><![CDATA[MySQL Query]]></category>
		<category><![CDATA[MySQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=2103</guid>

					<description><![CDATA[In this post, I am sharing one script to generate TRUNCATE TABLE script for all tables of MySQL Database Server. Generally, Database Developer creates a testing tables in development or report database server and even sometimes it is required to TRUNCATE all tables of a database. I have prepared one small script using INFORMATION_SCHEMA.TABLES which [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F09%2Fmysql-how-to-truncate-all-tables-of-a-database%2F&amp;linkname=MySQL%3A%20How%20to%20TRUNCATE%20all%20Tables%20of%20a%20Database%3F" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F09%2Fmysql-how-to-truncate-all-tables-of-a-database%2F&amp;linkname=MySQL%3A%20How%20to%20TRUNCATE%20all%20Tables%20of%20a%20Database%3F" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F09%2Fmysql-how-to-truncate-all-tables-of-a-database%2F&amp;linkname=MySQL%3A%20How%20to%20TRUNCATE%20all%20Tables%20of%20a%20Database%3F" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F09%2Fmysql-how-to-truncate-all-tables-of-a-database%2F&amp;linkname=MySQL%3A%20How%20to%20TRUNCATE%20all%20Tables%20of%20a%20Database%3F" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F09%2Fmysql-how-to-truncate-all-tables-of-a-database%2F&amp;linkname=MySQL%3A%20How%20to%20TRUNCATE%20all%20Tables%20of%20a%20Database%3F" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F09%2Fmysql-how-to-truncate-all-tables-of-a-database%2F&amp;linkname=MySQL%3A%20How%20to%20TRUNCATE%20all%20Tables%20of%20a%20Database%3F" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F09%2Fmysql-how-to-truncate-all-tables-of-a-database%2F&#038;title=MySQL%3A%20How%20to%20TRUNCATE%20all%20Tables%20of%20a%20Database%3F" data-a2a-url="https://www.dbrnd.com/2016/09/mysql-how-to-truncate-all-tables-of-a-database/" data-a2a-title="MySQL: How to TRUNCATE all Tables of a Database?"></a></p><p>In this post, I am sharing one script to generate TRUNCATE TABLE script for all tables of MySQL Database Server. </p>
<p>Generally, Database Developer creates a testing tables in development or report database server and even sometimes it is required to TRUNCATE all tables of a database. </p>
<p>I have prepared one small script using INFORMATION_SCHEMA.TABLES which generates TRUNCATE TABLE script for all tables and you can also apply filters like: database_name, table_name.</p>
<pre class="crayon-plain-tag">SELECT CONCAT('TRUNCATE TABLE ',table_schema,'.',TABLE_NAME, ';') 
FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema IN ('database_name')</pre> </p>
<p>You can copy the result of this script and can perform TRUNCATE operation for multiple tables. </p>
<blockquote><p>During TRUNCATE operation if you get any error like foreign key constraint fail, then you can enable and disable FOREIGN_KEY_CHECKS.</p></blockquote>
<p><strong>Error like:</strong></p>
<pre class="crayon-plain-tag">ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails</pre> </p>
<p><strong>Disable Foreign Key:</strong></p><pre class="crayon-plain-tag">SET FOREIGN_KEY_CHECKS=0;</pre><p> </p>
<p><strong>Enable Foreign Key:</strong></p><pre class="crayon-plain-tag">SET FOREIGN_KEY_CHECKS=1;</pre><p> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/09/mysql-how-to-truncate-all-tables-of-a-database/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>MySQL: How to Enable and Disable Foreign Key Constraint?</title>
		<link>https://www.dbrnd.com/2016/04/mysql-how-to-enable-and-disable-foreign-key-constraint/</link>
					<comments>https://www.dbrnd.com/2016/04/mysql-how-to-enable-and-disable-foreign-key-constraint/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 23 Apr 2016 20:45:40 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[foreign key]]></category>
		<category><![CDATA[FOREIGN_KEY_CHECKS]]></category>
		<category><![CDATA[MySQL Command]]></category>
		<category><![CDATA[MySQL Database Administrator]]></category>
		<category><![CDATA[MySQL Database Designing]]></category>
		<category><![CDATA[MySQL Database Programming]]></category>
		<category><![CDATA[MySQL Error]]></category>
		<category><![CDATA[MySQL Performance Tunning]]></category>
		<category><![CDATA[MySQL Query]]></category>
		<category><![CDATA[MySQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=2162</guid>

					<description><![CDATA[In this post, I am sharing a script on how to enable and disable Foreign Key constraint in MySQL. During data migration and testing purpose, Database Developer requires disabling Foreign key constraint. Once you disable the constraint, later you might require enabling again, but during this exercise make sure that all your data changes are [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fmysql-how-to-enable-and-disable-foreign-key-constraint%2F&amp;linkname=MySQL%3A%20How%20to%20Enable%20and%20Disable%20Foreign%20Key%20Constraint%3F" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fmysql-how-to-enable-and-disable-foreign-key-constraint%2F&amp;linkname=MySQL%3A%20How%20to%20Enable%20and%20Disable%20Foreign%20Key%20Constraint%3F" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fmysql-how-to-enable-and-disable-foreign-key-constraint%2F&amp;linkname=MySQL%3A%20How%20to%20Enable%20and%20Disable%20Foreign%20Key%20Constraint%3F" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fmysql-how-to-enable-and-disable-foreign-key-constraint%2F&amp;linkname=MySQL%3A%20How%20to%20Enable%20and%20Disable%20Foreign%20Key%20Constraint%3F" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fmysql-how-to-enable-and-disable-foreign-key-constraint%2F&amp;linkname=MySQL%3A%20How%20to%20Enable%20and%20Disable%20Foreign%20Key%20Constraint%3F" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fmysql-how-to-enable-and-disable-foreign-key-constraint%2F&amp;linkname=MySQL%3A%20How%20to%20Enable%20and%20Disable%20Foreign%20Key%20Constraint%3F" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fmysql-how-to-enable-and-disable-foreign-key-constraint%2F&#038;title=MySQL%3A%20How%20to%20Enable%20and%20Disable%20Foreign%20Key%20Constraint%3F" data-a2a-url="https://www.dbrnd.com/2016/04/mysql-how-to-enable-and-disable-foreign-key-constraint/" data-a2a-title="MySQL: How to Enable and Disable Foreign Key Constraint?"></a></p><p>In this post, I am sharing a script on how to enable and disable Foreign Key constraint in MySQL. </p>
<p>During data migration and testing purpose, Database Developer requires disabling Foreign key constraint.</p>
<blockquote><p>Once you disable the constraint, later you might require enabling again, but during this exercise make sure that all your data changes are correct, and as per the constraint rule otherwise, you cannot enable those constraints. It violates data integrity rules. </p></blockquote>
<p>You can perform disable/enable for both global and session levels of MySQL. </p>
<p><strong>At Session level:</strong></p>
<blockquote><p><strong>To Disable:</strong></p>
<pre class="crayon-plain-tag">SET FOREIGN_KEY_CHECKS=0;</pre> </p>
<p><strong>To Enable:</strong></p>
<pre class="crayon-plain-tag">SET FOREIGN_KEY_CHECKS=1;</pre>
</p></blockquote>
<p><strong>At Global level:</strong></p>
<blockquote><p><strong>To Disable:</strong></p><pre class="crayon-plain-tag">SET GLOBAL FOREIGN_KEY_CHECKS=0;</pre><p> </p>
<p><strong>To Enable:</strong></p><pre class="crayon-plain-tag">SET GLOBAL FOREIGN_KEY_CHECKS=1;</pre><p>
</p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/04/mysql-how-to-enable-and-disable-foreign-key-constraint/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
	</channel>
</rss>
