VARCHAR2 Data Type - Oracle to MariaDB Migration

In Oracle, the VARCHAR2(n) data type stores variable-length character strings up to n bytes (default) or characters with the maximum of 4000 or 32,767 bytes if MAX_STRING_SIZE initialization parameter is set to EXTENDED (not set by default).

In MariaDB Oracle compatibility mode, you can also use VARCHAR2(n) that can store up to 65,535 characters. But effective maximum length is subject to the maximum row size limit of 65,535 bytes (shared among all columns) and the character set used.

Oracle:

  CREATE TABLE specs
  (
    note   VARCHAR2(30),
    name VARCHAR2(100 CHAR),
    item   VARCHAR2(50 BYTE)
  );

MariaDB - Oracle Compatibility:

  CREATE TABLE specs
  (
    note   VARCHAR2(30),
    name VARCHAR2(100),     -- CHAR length semantics is not supported (this is default)
    item   VARCHAR2(50)        -- BYTE length semantics is not supported (length should be adjusted for character set)
  );

Overview

Conversion summary:

Oracle MariaDB - Oracle Compatibility
Syntax VARCHAR2(n [CHAR | BYTE]) VARCHAR2(n)
Parameter n is the number of characters or bytes (default) n is the number of characters
Range 1 ⇐ n ⇐ 4000 or 32,767 (if MAX_STRING_SIZE=EXTENDED) 0 ⇐ n ⇐ 65,535
(with 65,535 bytes row limit )
Default n must be specified n must be specified

For more information, see Oracle to MariaDB Migration - Oracle Compatibility Mode.