<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
  <channel>
    <title>Blog entries tagged sql :: mwop.net</title>
    <description>Blog entries tagged sql :: mwop.net</description>
    <pubDate>Wed, 08 Apr 2026 15:34:00 -0500</pubDate>
    <generator>Laminas_Feed_Writer 2 (https://getlaminas.org)</generator>
    <link>https://mwop.net/blog/tag/sql</link>
    <atom:link rel="self" type="application/rss+xml" href="https://mwop.net/blog/tag/sql/rss.xml"/>
    <item>
      <title>SQL ENUM Modification</title>
      <pubDate>Wed, 08 Apr 2026 15:34:00 -0500</pubDate>
      <link>https://mwop.net/blog/2026-04-08-sql-enum-modification.html</link>
      <guid>https://mwop.net/blog/2026-04-08-sql-enum-modification.html</guid>
      <author>contact@mwop.net (Matthew Weier O'Phinney)</author>
      <dc:creator>Matthew Weier O'Phinney</dc:creator>
      <content:encoded><![CDATA[<p>I'm doing a little DB work recently, and needing to choose how to represent certain data in the database. For a few fields, ENUM would be the correct choice, but there's a possibility I would need to expand the ENUM later to add values.</p>
<p>My question: is this safe?</p>


<p>The short answer, in my research, is &quot;yes&quot;, but with caveats.</p>
<p>For Postgres, it's trivial; you can easily add values to ENUM types:</p>
<pre><code class="language-sql hljs sql" data-lang="sql"><span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">TYPE</span> some_previously_defined_enum <span class="hljs-keyword">ADD</span> <span class="hljs-keyword">VALUE</span> <span class="hljs-string">'new-value'</span>;
</code></pre>
<p>For MySQL, it's a bit more complex. ENUMs are defined within the table schema, and to change them, you use an <code>ALTER TABLE</code> statement:</p>
<pre><code class="language-sql hljs sql" data-lang="sql"><span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">TABLE</span> some_table
<span class="hljs-keyword">MODIFY</span> some_previously_defined_enum ENUM(<span class="hljs-string">'value-1'</span>,<span class="hljs-string">'value-2'</span>);
</code></pre>
<p>Essentially, you're <em>replacing</em> the definition. This is fine... so long as you don't change the order, or remove any previously defined value in the ENUM. In other words, <em>append</em> to the existing list if you want to safely change it.</p>


<div class="h-entry">
    <img class="u-photo photo" width="50" src="https://avatars0.githubusercontent.com/u/25943?v=3&u=79dd2ea1d4d8855944715d09ee4c86215027fa80&s=140" alt="matthew">
    <a class="u-url u-uid p-name" href="https://mwop.net/blog/2026-04-08-sql-enum-modification.html">SQL ENUM Modification</a> was originally
    published <time class="dt-published" datetime="2026-04-08T15:34:00-05:00">8 April 2026</time>
    on <a href="https://mwop.net">https://mwop.net</a> by
    <a rel="author" class="p-author" href="https://mwop.net">Matthew Weier O&#039;Phinney</a>.
</div>
]]></content:encoded>
      <slash:comments>0</slash:comments>
    </item>
  </channel>
</rss>
