How can I create a temporary table in mariadb or mysql?
<p>Now, I'm migrating mssql to mariadb(mysql). Mssql has with clause(with A as ()), but mysql has not with clause. So I'm using "create temporary table", but some error occurred.</p>

<p>Example,</p>

<pre><code>CREATE TEMPORARY TABLE TMP(
    SELECT CAST(DATE_FORMAT(NOW(), '%Y-%m-%d %T.%f') AS CHAR(19)) AS REGDT
);
</code></pre>

<p>and this is error code</p>

<blockquote>
  <p>MySQL Database Error: Truncated incorrect CHAR(19) value: '2016-06-27 10:34:34.000000'</p>
</blockquote>

<p>What is wrong?</p>

<p>This is my query.</p>

<pre><code>CREATE TEMPORARY TABLE TMP(
  SELECT DEPTCODE, DEPTNAME, USEYN, HIGHDEPTCODE, 
         CAST(DATE_FORMAT(REGDT, '%Y-%m-%d %T.%f') AS CHAR(19)) AS REGDT,
         0 AS LEV, CAST(DEPTCODE AS CHAR(255)) AS SORT, DEPTORDER 
    FROM TBDEPARTMENT
   WHERE DEPTCODE = '1000');
</code></pre>