<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://sqlzoo.net/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://sqlzoo.net/w/index.php?title=DROP_TABLE_problems:_Foreign_key_references.&amp;feed=atom&amp;action=history</id>
		<title>DROP TABLE problems: Foreign key references. - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://sqlzoo.net/w/index.php?title=DROP_TABLE_problems:_Foreign_key_references.&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://sqlzoo.net/w/index.php?title=DROP_TABLE_problems:_Foreign_key_references.&amp;action=history"/>
		<updated>2013-05-22T08:01:24Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.20.4</generator>

	<entry>
		<id>http://sqlzoo.net/w/index.php?title=DROP_TABLE_problems:_Foreign_key_references.&amp;diff=1438&amp;oldid=prev</id>
		<title>Marek: Created page with &quot;DROP TABLE problems: Foreign key references. &lt;div class='ht'&gt; &lt;div class=params&gt;schema:scott&lt;/div&gt; &lt;div&gt; You may not drop a table if it is referenced by another table. &lt;/div&gt; ...&quot;</title>
		<link rel="alternate" type="text/html" href="http://sqlzoo.net/w/index.php?title=DROP_TABLE_problems:_Foreign_key_references.&amp;diff=1438&amp;oldid=prev"/>
				<updated>2012-07-17T09:43:24Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;DROP TABLE problems: Foreign key references. &amp;lt;div class=&amp;#039;ht&amp;#039;&amp;gt; &amp;lt;div class=params&amp;gt;schema:scott&amp;lt;/div&amp;gt; &amp;lt;div&amp;gt; You may not drop a table if it is referenced by another table. &amp;lt;/div&amp;gt; ...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;DROP TABLE problems: Foreign key references.&lt;br /&gt;
&amp;lt;div class='ht'&amp;gt;&lt;br /&gt;
&amp;lt;div class=params&amp;gt;schema:scott&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
You may not drop a table if it is referenced by another table.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=sql class='tidy'&amp;gt;&lt;br /&gt;
DROP TABLE t_b;&lt;br /&gt;
DROP TABLE t_a&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=sql class='setup'&amp;gt;&lt;br /&gt;
CREATE TABLE t_a (i INTEGER NOT NULL PRIMARY KEY);&lt;br /&gt;
CREATE TABLE t_b (j INTEGER,&lt;br /&gt;
FOREIGN KEY(j) REFERENCES t_a(i));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;DROP TABLE t_a&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;ecomm e-mysql&amp;quot; style=&amp;quot;display: none&amp;quot;&amp;gt;Foreign keys are not implemented in MySQL so  this problem does not arise.&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;ecomm e-oracle&amp;quot; style=&amp;quot;display: none&amp;quot;&amp;gt;The CASCADE CONSTRAINTS clause can be used to remove the references. &amp;lt;pre&amp;gt;DROP TABLE t_a CASCADE CONSTRAINTS&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;ecomm e-sqlserver&amp;quot; style=&amp;quot;display: none&amp;quot;&amp;gt;&lt;br /&gt;
We can find out what the foreign keys are using&lt;br /&gt;
&amp;lt;tt&amp;gt;sp_help ''table_name''&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;ecomm e-mysql&amp;quot; style=&amp;quot;display: none&amp;quot;&amp;gt;The (implicit) trigger gets dropped automatically.&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
{{CREATE and DROP ref}}&lt;/div&gt;</summary>
		<author><name>Marek</name></author>	</entry>

	</feed>