<?xml version="1.0"?>
<rss version="2.0">
<channel>
  <title>PoStorm - MySQL category</title>
  <link>http://www.davepullin.com:80/categories/programming/MySQL/</link>
  <description>A Storm of Pos. &lt;a href=&#039;/pages/po.html&#039; style=&#039;color:white&#039;&gt;What is a po?&lt;/a&gt; &lt;a href=&#039;/pages/PoStorm.html&#039; style=&#039;color:white&#039;&gt;What is a PoStorm?&lt;/a&gt;</description>
  <language>en</language>
  <copyright>Dave Pullin</copyright>
  <lastBuildDate>Mon, 14 Dec 2009 16:32:00 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  
  
  <item>
    <title>Like column</title>
    <link>http://www.davepullin.com:80/2008/06/23/like_column.html</link>
    
      
        <description>
          &lt;h2&gt;Like column&lt;/h2&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;span style=&#034;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&#034;&gt;Create table t1 ( x int unsigned default 911, y like x )&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;span style=&#034;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&#034;&gt;Create table t2 (x like t1.x)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h3&gt;Tricky extension &lt;/h3&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;span style=&#034;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&#034;&gt;Create table t2 (x always like t1.x)&lt;/span&gt;&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;Meaning that &lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;span style=&#034;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&#034;&gt;alter table t1 modify x int signed&lt;/span&gt;&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;implies a corresponding alter on t2&lt;/p&gt;
&lt;span style=&#034;font-size: 12pt; font-family: &amp;quot;Times New Roman&amp;quot;;&#034;&gt;The purpose of &amp;lsquo;LIKE&amp;rsquo; is to avoid multiply specifying that which must always be the same. LIKE both documents the dependency, and eliminates the possibility of inconsistency. ALWAYS LIKE prevents the inconsistency developing in the future.&lt;/span&gt;
        </description>
      
      
    
    
    
    <category>MySQL_Suggestions</category>
    
    <comments>http://www.davepullin.com:80/2008/06/23/like_column.html#comments</comments>
    <guid isPermaLink="true">http://www.davepullin.com:80/2008/06/23/like_column.html</guid>
    <pubDate>Mon, 23 Jun 2008 17:17:00 GMT</pubDate>
  </item>
  
  <item>
    <title>ALTER Initial</title>
    <link>http://www.davepullin.com:80/2008/06/15/alter_initial.html</link>
    
      
        <description>
          &lt;h2&gt;ALTER Initial&lt;/h2&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;span style=&#034;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&#034;&gt;Alter table this,that&lt;/span&gt; (ie. ALTER with multiple changes) appears to be optimized perform a single pass thru a table (at least sometimes) to perform the multiple changes. Some changes require column expression evaluation. These could be done with the alter&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;!--[if !supportEmptyParas]--&gt;&amp;nbsp;&lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;E.g.&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;span style=&#034;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&#034;&gt;Alter table xxx, add column negative bit initial quantity&amp;lt;0, modify quantity int unsigned initial abs(quantity)&lt;/span&gt;&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;This changes the representation of a column (&amp;lsquo;quantity&amp;rsquo;) from a signed integer to an unsigned integer with a flag (&amp;lsquo;negative&amp;rsquo;) to indicate that quantity is negative.&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;span style=&#034;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&#034;&gt;Alter table sales add unitprice dec(6,2) initial totalprice/quantity , drop totalprice&lt;/span&gt;&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;This alters a table, in a single pass, from recording the quantity and total price of sales, to recording quantity and unit price of sales.&lt;span style=&#034;&#034;&gt;&amp;nbsp; &lt;/span&gt;Without this extension it requires three passes through the table (1. Alter Add unitprice, 2 update set unitprice, 3 alter drop totalprice).&lt;/p&gt;
&lt;span style=&#034;font-size: 12pt; font-family: &amp;quot;Times New Roman&amp;quot;;&#034;&gt;The meaning of the &amp;lsquo;initial&amp;rsquo; clause is an expression that is computed based on the values in the row at the time the ALTER is performed for each row to set (or update) the value of the column.&lt;/span&gt;
        </description>
      
      
    
    
    
    <category>MySQL_Suggestions</category>
    
    <comments>http://www.davepullin.com:80/2008/06/15/alter_initial.html#comments</comments>
    <guid isPermaLink="true">http://www.davepullin.com:80/2008/06/15/alter_initial.html</guid>
    <pubDate>Sun, 15 Jun 2008 17:14:00 GMT</pubDate>
  </item>
  
  <item>
    <title>BitOf(column,string)</title>
    <link>http://www.davepullin.com:80/2008/06/14/bitofcolumn_string.html</link>
    
      
        <description>
          &lt;h2&gt;BitOf(column,string)&lt;/h2&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;Manipulating Column Type SETs cannot be readily (or efficiently) manipulated&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;Eg. Suppage the column &lt;span style=&#034;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&#034;&gt;Flags&lt;/span&gt; is defined as &lt;span style=&#034;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&#034;&gt;set(&amp;lsquo;a&amp;rsquo;,&amp;rsquo;b&amp;rsquo;,&amp;rsquo;c&amp;rsquo;)&lt;/span&gt;&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;span style=&#034;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&#034;&gt;Update flags&lt;/span&gt; = flags_with_b_flipped.&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;This can be written using string manipulation &amp;ndash; although it is messy - or can be written as&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;span style=&#034;&#034;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&#034;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&#034;&gt;Flags=flags^2&lt;span style=&#034;&#034;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;/* b=~b */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;But this depends on &amp;lsquo;b&amp;rsquo; being the second item in the set declaration. &lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;span style=&#034;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&#034;&gt;Flags=flags^bitOf(flags,&amp;rsquo;b&amp;rsquo;)&lt;/span&gt;&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;span style=&#034;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&#034;&gt;BitOf(column,string)&lt;/span&gt; means the bit-mask that represents string in the column definition. (not the current value of).&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;!--[if !supportEmptyParas]--&gt;&lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;span style=&#034;font-size: 12pt; font-family: &amp;quot;Times New Roman&amp;quot;;&#034;&gt;&lt;span style=&#034;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&#034;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;
        </description>
      
      
    
    
    
    <category>MySQL_Suggestions</category>
    
    <comments>http://www.davepullin.com:80/2008/06/14/bitofcolumn_string.html#comments</comments>
    <guid isPermaLink="true">http://www.davepullin.com:80/2008/06/14/bitofcolumn_string.html</guid>
    <pubDate>Sat, 14 Jun 2008 17:07:00 GMT</pubDate>
  </item>
  
  <item>
    <title>Limit [while|until] expression</title>
    <link>http://www.davepullin.com:80/2008/06/13/limit_whileuntil_expression.html</link>
    
      
        <description>
          &lt;h2&gt;Limit [while|until] expression&lt;/h2&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;Performing sequential operations on set is a bitch, but this might help.&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;The MySQL extension &amp;lsquo;limit&amp;rsquo; &amp;hellip;&lt;/p&gt;
&lt;p class=&#034;MsoNormal&#034;&gt;&lt;!--[if !supportEmptyParas]--&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;span style=&#034;font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;&#034;&gt;Select * from budget_candidates order by priority limit while sum(cost)&amp;lt;1000.00&lt;/span&gt;
        </description>
      
      
    
    
    
    <category>MySQL_Suggestions</category>
    
    <comments>http://www.davepullin.com:80/2008/06/13/limit_whileuntil_expression.html#comments</comments>
    <guid isPermaLink="true">http://www.davepullin.com:80/2008/06/13/limit_whileuntil_expression.html</guid>
    <pubDate>Fri, 13 Jun 2008 16:51:00 GMT</pubDate>
  </item>
  
  </channel>
</rss>
