EMPTY_BLOB Function - Oracle to MySQL Migration

In Oracle, the EMPTY_BLOB function creates an empty BLOB locator i.e. an empty (with 0 length), but non-NULL BLOB value.

In MySQL, you can use x'' constant (empty binary string).

Oracle:

  -- A sample table
  CREATE TABLE t1 (
    c1 BLOB DEFAULT EMPTY_BLOB()
  );

MySQL:

  -- A sample table
  CREATE TABLE t1 (
    c1 LONGBLOB DEFAULT (x'')
  );
  /* Query OK, 0 rows affected */

Note that for a BLOB column, you have to enclose the DEFAULT value with parentheses, otherwise you will get the error: ERROR 1101 (42000): BLOB, TEXT, GEOMETRY or JSON column can't have a default value.

For more information, see Oracle to MySQL Migration.