<?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; db</title>
	<atom:link href="http://cornempire.net/tag/db/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>Useful Database Commands</title>
		<link>http://cornempire.net/2010/05/05/useful-database-commands/</link>
		<comments>http://cornempire.net/2010/05/05/useful-database-commands/#comments</comments>
		<pubDate>Wed, 05 May 2010 18:52:37 +0000</pubDate>
		<dc:creator>cornmaster</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://cornempire.net/?p=188</guid>
		<description><![CDATA[Here are some neat database commands I recently came across while I was trying to get statistics and status information on some mysql and postgres databases. Postgres This will give you a list of all of the databases in the server.* select datname from pg_database; * If you don&#8217;t know how to connect to postgres <a href='http://cornempire.net/2010/05/05/useful-database-commands/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Here are some neat database commands I recently came across while I was trying to get statistics and status information on some mysql and postgres databases.</p>
<h2>Postgres</h2>
<p>This will give you a list of all of the databases in the server.*<br />
<code>select datname from pg_database;</code></p>
<p>* If you don&#8217;t know how to connect to postgres from the command line, don&#8217;t fear (well fear a little).  What I had to do was <em>su</em> to the user that is a DB user, and then run <em>/usr/local/pgsql/bin/psql</em>  This launched a command line client (without needing a password), that let me query the server.  I can&#8217;t provide a better understanding then that, as this is the first time I&#8217;ve ever interacted with a postgres server.</p>
<p>This tells you how big a particular database is.<br />
<code>SELECT pg_size_pretty(pg_database_size('xythosdocs'));</code><br />
 The output is like this:<br />
<code> pg_size_pretty<br />
----------------<br />
 2834 MB<br />
(1 row)<br />
</code></p>
<h2>Mysql</h2>
<p>Get all database sizes:<br />
<code>SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB", sum( data_free )/ 1024 / 1024 "Free Space in MB" FROM information_schema.TABLES GROUP BY table_schema;</code><br />
Produces output like this on the command line:</p>
<pre><code>
+--------------------+----------------------+------------------+
| Data Base Name     | Data Base Size in MB | Free Space in MB |
+--------------------+----------------------+------------------+
| blogadmin          |           0.35750008 |       0.00098896 |
| blogs              |          90.60342026 |      27.73141003 |
| information_schema |           0.00781250 |       0.00000000 |
| musicschedule      |           0.00548172 |       0.00020599 |
| mysql              |           0.54032421 |       0.00000000 |
| phpflash           |           0.77745819 |       0.00000000 |
+--------------------+----------------------+------------------+</code></pre>
<p>Get some status information on the sever.  Run this from the command line:<br />
<code>mysqladmin -uroot -p status</code><br />
Phpmyadmin also provides a lot of process status information if you have that installed.</p>
]]></content:encoded>
			<wfw:commentRss>http://cornempire.net/2010/05/05/useful-database-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>

