title: MariaDB Virtual Columns - Can I have a hash?
body: <p>MariaDB has virtual columns that allow one to automatically perform actions on other column data. For example, this is good if you want to display data in different units of metric measurement simply by dividing by 10 or 1000 as shown by the table definition below:</p>
  
  <pre><code>CREATE TABLE a (
       id INT NOT NULL AUTO_INCREMENT,
       distance_meters INT (11),
       distance_kilometers FLOAT (11,3) AS (distance_meters / 1000) VIRTUAL,
       PRIMARY KEY ( id )
  ) ENGINE=InnoDB;
  </code></pre>
  
  <p>However, how do I create a virtual column that is the hash of a subset of table columns? E.g. The table below (which doesnt work) aims to hash the name and salary, so that I can easily check again later if any of the employees names or salaries have changed by comparing against a previous hash list. I don't want the hash of the entire row.</p>
  
  <pre><code>CREATE TABLE employees (
      id INT NOT NULL,
      name VARCHAR(200),
      salary INT(12),
      age int(3),
      hash VARCHAR(AS (MD5(concat(name, salary)))) PERSISTENT,
      PRIMARY KEY ( id )
  ) ENGINE=InnoDB;
  </code></pre>