<?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>youdidwhatwithtsql.com &#187; partitioning</title>
	<atom:link href="http://www.youdidwhatwithtsql.com/tag/partitioning/feed" rel="self" type="application/rss+xml" />
	<link>http://www.youdidwhatwithtsql.com</link>
	<description>making DBAs everywhere curse!</description>
	<lastBuildDate>Tue, 31 Jan 2012 12:21:23 +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>For RANGE partitions each partition must be defined</title>
		<link>http://www.youdidwhatwithtsql.com/for-range-partitions-each-partition-must-be-defined/815</link>
		<comments>http://www.youdidwhatwithtsql.com/for-range-partitions-each-partition-must-be-defined/815#comments</comments>
		<pubDate>Fri, 09 Jul 2010 12:08:31 +0000</pubDate>
		<dc:creator>Rhys</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[partition]]></category>
		<category><![CDATA[partitioning]]></category>

		<guid isPermaLink="false">http://www.youdidwhatwithtsql.com/for-range-partitions-each-partition-must-be-defined/815</guid>
		<description><![CDATA[If you encounter the following error when trying to create a partitioned table in MySQL Error Code : 1492 For RANGE partitions each partition must be defined Assuming you have defined your partitions then you probably have a syntax error. Take the following incorrect example. ?View Code MYSQLCREATE TABLE People &#40; PersonId INTEGER NOT NULL [...]<p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/for-range-partitions-each-partition-must-be-defined/815">For RANGE partitions each partition must be defined</a></p>
]]></description>
			<content:encoded><![CDATA[<p>If you encounter the following error when trying to create a partitioned table in MySQL</p>
<pre>Error Code : 1492
For RANGE partitions each partition must be defined</pre>
<p>Assuming you have defined your partitions then you probably have a syntax error. Take the following incorrect example.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p815code3'); return false;">View Code</a> MYSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8153"><td class="code" id="p815code3"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">TABLE</span> People
<span style="color: #FF00FF;">&#40;</span>
	PersonId <span style="color: #999900; font-weight: bold;">INTEGER</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #FF9900; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #000033;">,</span>
	FirstName <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">50</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
	LastName <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">50</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
	DateOfBirth <span style="color: #999900; font-weight: bold;">DATE</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
	Telephone <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">30</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
	Email <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">200</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
	GroupId <span style="color: #999900; font-weight: bold;">SMALLINT</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
	<span style="color: #990099; font-weight: bold;">PRIMARY KEY</span> <span style="color: #FF00FF;">&#40;</span>PersonId<span style="color: #000033;">,</span> GroupId<span style="color: #FF00FF;">&#41;</span>
<span style="color: #FF00FF;">&#41;</span>
PARTITION BY RANGE <span style="color: #FF00FF;">&#40;</span>GroupId<span style="color: #FF00FF;">&#41;</span>
PARTITION p0 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">100</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
PARTITION p1 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">200</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
PARTITION p2 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">300</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
PARTITION p3 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">400</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
PARTITION p4 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">500</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
PARTITION p5 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">600</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
PARTITION p6 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">700</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></td></tr></table></div>

<p>The above statement is not syntactically correct but the error thrown in this case is not particularly helpful. All that is missing here is a couple of braces around the partition range definitions. The below DDL statement is correct.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p815code4'); return false;">View Code</a> MYSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8154"><td class="code" id="p815code4"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">TABLE</span> People
<span style="color: #FF00FF;">&#40;</span>
	PersonId <span style="color: #999900; font-weight: bold;">INTEGER</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #FF9900; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #000033;">,</span>
	FirstName <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">50</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
	LastName <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">50</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
	DateOfBirth <span style="color: #999900; font-weight: bold;">DATE</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
	Telephone <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">30</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
	Email <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">200</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
	GroupId <span style="color: #999900; font-weight: bold;">SMALLINT</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
	<span style="color: #990099; font-weight: bold;">PRIMARY KEY</span> <span style="color: #FF00FF;">&#40;</span>PersonId<span style="color: #000033;">,</span> GroupId<span style="color: #FF00FF;">&#41;</span>
<span style="color: #FF00FF;">&#41;</span>
PARTITION BY RANGE <span style="color: #FF00FF;">&#40;</span>GroupId<span style="color: #FF00FF;">&#41;</span>
<span style="color: #FF00FF;">&#40;</span>
	PARTITION p0 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">100</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
	PARTITION p1 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">200</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
	PARTITION p2 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">300</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
	PARTITION p3 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">400</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
	PARTITION p4 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">500</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
	PARTITION p5 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">600</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
	PARTITION p6 <span style="color: #990099; font-weight: bold;">VALUES</span> LESS THAN <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">700</span><span style="color: #FF00FF;">&#41;</span>
<span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></td></tr></table></div>

<p><map name='google_ad_map_815_a45beff5d2e172f6'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/815?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_815_a45beff5d2e172f6' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=815&amp;url=http%3A%2F%2Fwww.youdidwhatwithtsql.com%2Ffor-range-partitions-each-partition-must-be-defined%2F815' title="For RANGE partitions each partition must be defined" alt=" For RANGE partitions each partition must be defined" /></p><p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/for-range-partitions-each-partition-must-be-defined/815">For RANGE partitions each partition must be defined</a></p>
<div class="none"><div class="g-plusone" data-href="http://www.youdidwhatwithtsql.com/for-range-partitions-each-partition-must-be-defined/815" size="standard" count="true"></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.youdidwhatwithtsql.com/for-range-partitions-each-partition-must-be-defined/815/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

