<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="text">Blog entries tagged mysql :: mwop.net</title>
  <updated>2026-04-08T15:34:00-05:00</updated>
  <generator uri="https://getlaminas.org" version="2">Laminas_Feed_Writer</generator>
  <link rel="alternate" type="text/html" href="https://mwop.net/blog/tag/mysql"/>
  <link rel="self" type="application/atom+xml" href="https://mwop.net/blog/tag/mysql/atom.xml"/>
  <id>https://mwop.net/blog/tag/mysql</id>
  <entry xmlns:xhtml="http://www.w3.org/1999/xhtml">
    <title type="html"><![CDATA[SQL ENUM Modification]]></title>
    <published>2026-04-08T15:34:00-05:00</published>
    <updated>2026-04-08T15:34:00-05:00</updated>
    <link rel="alternate" type="text/html" href="https://mwop.net/blog/2026-04-08-sql-enum-modification.html"/>
    <id>https://mwop.net/blog/2026-04-08-sql-enum-modification.html</id>
    <author>
      <name>Matthew Weier O'Phinney</name>
      <email>contact@mwop.net</email>
      <uri>https://mwop.net</uri>
    </author>
    <content xmlns:xhtml="http://www.w3.org/1999/xhtml" type="xhtml">
      <xhtml:div xmlns:xhtml="http://www.w3.org/1999/xhtml"><xhtml: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.</xhtml:p>
<xhtml:p>My question: is this safe?</xhtml:p>
<xhtml:p>The short answer, in my research, is "yes", but with
caveats.</xhtml:p>
<xhtml:p>For Postgres, it's trivial; you can easily add values to ENUM
types:</xhtml:p>
<xhtml:pre><xhtml:code class="language-sql hljs sql" data-lang="sql"><xhtml:span class="hljs-keyword">ALTER</xhtml:span> <xhtml:span class="hljs-keyword">TYPE</xhtml:span> some_previously_defined_enum <xhtml:span class="hljs-keyword">ADD</xhtml:span> <xhtml:span class="hljs-keyword">VALUE</xhtml:span> <xhtml:span class="hljs-string">'new-value'</xhtml:span>;
</xhtml:code></xhtml:pre>
<xhtml:p>For MySQL, it's a bit more complex. ENUMs are defined within the
table schema, and to change them, you use an <xhtml:code>ALTER
TABLE</xhtml:code> statement:</xhtml:p>
<xhtml:pre><xhtml:code class="language-sql hljs sql" data-lang="sql"><xhtml:span class="hljs-keyword">ALTER</xhtml:span> <xhtml:span class="hljs-keyword">TABLE</xhtml:span> some_table
<xhtml:span class="hljs-keyword">MODIFY</xhtml:span> some_previously_defined_enum ENUM(<xhtml:span class="hljs-string">'value-1'</xhtml:span>,<xhtml:span class="hljs-string">'value-2'</xhtml:span>);
</xhtml:code></xhtml:pre>
<xhtml:p>Essentially, you're <xhtml:em>replacing</xhtml: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,
<xhtml:em>append</xhtml:em> to the existing list if you want to safely change
it.</xhtml:p>
<xhtml:div class="h-entry"><xhtml:img class="u-photo photo" width="50" src="https://avatars0.githubusercontent.com/u/25943?v=3&amp;u=79dd2ea1d4d8855944715d09ee4c86215027fa80&amp;s=140" alt="matthew"/> <xhtml:a class="u-url u-uid p-name" href="https://mwop.net/blog/2026-04-08-sql-enum-modification.html">SQL
ENUM Modification</xhtml:a> was originally published <xhtml:time class="dt-published" datetime="2026-04-08T15:34:00-05:00">8 April
2026</xhtml:time> on <xhtml:a href="https://mwop.net">https://mwop.net</xhtml:a> by
<xhtml:a rel="author" class="p-author" href="https://mwop.net">Matthew
Weier O'Phinney</xhtml:a>.</xhtml:div>
</xhtml:div>
    </content>
  </entry>
</feed>
