<?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>BigSmoke &#187; DB</title>
	<atom:link href="http://blog.bigsmoke.us/tag/db/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.bigsmoke.us</link>
	<description>Smokes your problems, coughs fresh air.</description>
	<lastBuildDate>Sat, 04 Feb 2012 18:03:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Purging a MySQL database without losing meta data</title>
		<link>http://blog.bigsmoke.us/2008/07/12/purging-a-mysql-database</link>
		<comments>http://blog.bigsmoke.us/2008/07/12/purging-a-mysql-database#comments</comments>
		<pubDate>Sat, 12 Jul 2008 00:21:33 +0000</pubDate>
		<dc:creator>Rowan Rodrik</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[DB]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/?p=95</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>When I clone a production database to a development database, I always need to empty the development database first. I could never find an SQL command to completely purge a database, bur, recently, I learned something about MySQL that surprised me: MySQL doesn&#8217;t lose the user rights for a database when you drop it. So, purging a MySQL database (without losing any access data meta data about that DB) is as simple as issuing the following statements:</p>

<pre class="sql"><span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">DATABASE</span> my_development_db;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">DATABASE</span> my_development_db;</pre>

<p>Happy cloning! <img src='http://blog.bigsmoke.us/wp-factory/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2008/07/12/purging-a-mysql-database/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unique constraints and indexes in PostgreSQL</title>
		<link>http://blog.bigsmoke.us/2007/02/02/postgresql-unique-constraints-and-indexes</link>
		<comments>http://blog.bigsmoke.us/2007/02/02/postgresql-unique-constraints-and-indexes#comments</comments>
		<pubDate>Fri, 02 Feb 2007 22:11:29 +0000</pubDate>
		<dc:creator>Rowan Rodrik</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[DB]]></category>
		<category><![CDATA[pgAdmin]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Sicirec]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/2007/02/02/postgresql-unique-contraints-and-indexes</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>This afternoon, I had to add a unique index for some table in the Sicirec <a href="http://www.postgresql.org/">PostgreSQL</a> database. I had already assumed that I needed to use <tt>CREATE UNIQUE INDEX</tt> to create my new unique index until I noticed, thanks to <a href="http://www.pgadmin.org/">pgAdmin</a>&#8216;s clear GUI, that some tables clearly had unique constraints <em>and</em> unique indexes while one table lacked a unique <em>constraint</em> and only had an unique index defined.</p>

<p>This motivated me to take a closer look at PostgreSQL&#8217;s documentation <a href="http://www.postgresql.org/docs/8.1/interactive/indexes-unique.html">on unique indexes</a>:</p>

<blockquote cite="http://www.postgresql.org/docs/8.1/interactive/indexes-unique.html">
<p><b>Note: </b> The preferred way to add a unique constraint to a table is <tt class="literal">ALTER TABLE ... ADD CONSTRAINT</tt>.  The use of indexes to enforce unique constraints could be considered an implementation detail that should not be accessed directly.  One should, however, be aware that there&#8217;s no need to manually create indexes on unique columns; doing so would just duplicate the automatically-created index.</p>
</blockquote>

<p>Grepping for <q><tt>CREATE UNIQUE INDEX</tt></q> in our migration history quickly revealed that the index which lacked an accompanying constraint was indeed created by <tt>CREATE UNIQUE INDEX</tt> instead of by <tt>ALTER TABLE ... ADD CONSTRAINT</tt>. So,  now I know that, indeed, I have to use <tt class="literal">ALTER TABLE ... ADD CONSTRAINT</tt> instead of <tt>CREATE UNIQUE INDEX</tt> to add unique constraints with accompanying indexes to existing tables.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2007/02/02/postgresql-unique-constraints-and-indexes/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

