<?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>CornEmpire Software &#187; alter table</title>
	<atom:link href="http://cornempire.net/tag/alter-table/feed/" rel="self" type="application/rss+xml" />
	<link>http://cornempire.net</link>
	<description>Tidbits about programming, web development, gaming and other random stuff.</description>
	<lastBuildDate>Sat, 31 Mar 2012 11:43:47 +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>Add Comments to Column &#8211; MySQL</title>
		<link>http://cornempire.net/2010/04/15/add-comments-to-column-mysql/</link>
		<comments>http://cornempire.net/2010/04/15/add-comments-to-column-mysql/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 11:27:00 +0000</pubDate>
		<dc:creator>cornmaster</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[alter table]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://cornempire.net/?p=173</guid>
		<description><![CDATA[So, you have a nice new database table, and you forgot (or couldn&#8217;t) add comments to the columns when you created it. I recently ran into this problem, and my usual internet searches didn&#8217;t turn up much.  One would expect a statement similar to this: ALTER COLUMN `columnname` ADD COMMENT 'a comment' However, that statement <a href='http://cornempire.net/2010/04/15/add-comments-to-column-mysql/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>So, you have a nice new database table, and you forgot (or couldn&#8217;t) add comments to the columns when you created it.  I recently ran into this problem, and my usual internet searches didn&#8217;t turn up much.  One would expect a statement similar to this:<br />
<code>ALTER COLUMN `columnname` ADD COMMENT 'a comment'</code><br />
However, that statement doesn&#8217;t exist.</p>
<p>If you have gotten to my post, you probably realize that there is no easy way to add comments (unless you have a nice application that does it for you).  The real statement is something along the lines of this:<br />
<code>ALTER TABLE `courses` CHANGE `courseid` `courseid` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'a new comment'<br />
</code></p>
<p>Which means you need to know the table definition, and restate it every time you want to change the comment.  If you are doing this in bulk, that is a pain in the butt.</p>
<p>So, I wrote this little script that will take a create table definition, and turn it into Alter Table commands, that will add comments to each of your columns.</p>
<p>All you need to do is run &#8216;SHOW CREATE TABLE `tablename`&#8217;  on your database table, and insert that definition into my <a href="/scripts/altertable/altertable.php">script here</a>, and it will spit out a series of Alter Table calls with a space for a comment appended to the end.</p>
<p>The script is very basic at this point, and expects the formatting as shown in the example.  The GUI I use, <a href="http://www.dbvis.com/">DbVisualizer</a>, as well as the mysql command line client spit this out.  So hopefully yours will to.  </p>
<p>If you find this useful, or run into any problems with the script, please let me know.</p>
<p>Edit (April 15, 2010): Uploaded v0.2.  Small mistake that was placing the column name in place of the table name.  Sorry to anyone that was used it before and noticed it.</p>
]]></content:encoded>
			<wfw:commentRss>http://cornempire.net/2010/04/15/add-comments-to-column-mysql/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

