<?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>scienceoss.com &#187; alter</title>
	<atom:link href="http://scienceoss.com/tags/alter/feed/" rel="self" type="application/rss+xml" />
	<link>http://scienceoss.com</link>
	<description>useful tidbits for using open source software in science</description>
	<lastBuildDate>Wed, 26 May 2010 03:34:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Foreign keys in MySQL</title>
		<link>http://scienceoss.com/foreign-keys-in-mysql/</link>
		<comments>http://scienceoss.com/foreign-keys-in-mysql/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 16:47:43 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[alter]]></category>
		<category><![CDATA[foreign key]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[SQLAlchemy]]></category>
		<category><![CDATA[tables]]></category>

		<guid isPermaLink="false">http://scienceoss.com/foreign-keys-in-mysql/</guid>
		<description><![CDATA[The default engine in MySQL, MyISAM, does not support foreign keys. You need foreign keys to use the SQLAlchemy Python package effectively. In order to use foreign keys, you need to convert your tables to the InnoDB engine: To add a foreign key to mytable where the unique keys are coming from othertable, use this: [...]]]></description>
			<content:encoded><![CDATA[<p>The default engine in MySQL, MyISAM, does not support foreign keys.  You need foreign keys to use the SQLAlchemy Python package effectively.  </p>
<p>In order to use foreign keys, you need to convert your tables to the InnoDB engine:</p>
<pre class="brush: sql; title: ; notranslate">
ALTER TABLE mytable ENGINE = INNODB;
</pre>
<p>To add a foreign key to <span class="c">mytable</span> where the unique keys are coming from <span class="c">othertable</span>, use this:</p>
<pre class="brush: sql; title: ; notranslate">
ALTER TABLE mytable ADD FOREIGN KEY (otherID) REFERENCES othertable (otherID);
</pre>
<p>If you run that same line several times, several identical foreign keys will be created, which will confuse SQLAlchemy.  In that case you need to delete the keys.  To do so, you need their name.  To see the name, use </p>
<pre class="brush: sql; title: ; notranslate">SHOW CREATE TABLE mytable;</pre>
<p>The foreign key&#8217;s label will be something that ends in something similar to <span class="c">fk_1</span> or <span class="c">fk_2</span>.  Using that label, you can then delete the foreign key:</p>
<pre class="brush: sql; title: ; notranslate">ALTER TABLE mytable DROP FOREIGN KEY mytable_dbfk_2;</pre>
]]></content:encoded>
			<wfw:commentRss>http://scienceoss.com/foreign-keys-in-mysql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Add or delete columns in a table in MySQL</title>
		<link>http://scienceoss.com/add-or-delete-columns-in-a-table-in-mysql/</link>
		<comments>http://scienceoss.com/add-or-delete-columns-in-a-table-in-mysql/#comments</comments>
		<pubDate>Mon, 17 Mar 2008 00:14:14 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[alter]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[tables]]></category>

		<guid isPermaLink="false">http://scienceoss.com/add-or-delete-columns-in-a-table-in-mysql/</guid>
		<description><![CDATA[Add a column to a table in the database: ALTER TABLE table_name ADD column_name datatype Delete a column from a table in the database: ALTER TABLE table_name DROP COLUMN column_name]]></description>
			<content:encoded><![CDATA[<p>Add a column to a table in the database:</p>
<pre class="prettyprint"><code class="code">
ALTER TABLE table_name
ADD column_name datatype
</code></pre>
<p>Delete a column from a table in the database:</p>
<pre class="prettyprint"><code class="code">
ALTER TABLE table_name
DROP COLUMN column_name</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://scienceoss.com/add-or-delete-columns-in-a-table-in-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

