Type Mappings

On this page Carat arrow pointing down

The MOLT Schema Conversion Tool and MOLT Fetch can be used to automatically generate schema for a CockroachDB cluster. By default, types are mapped from the source database to CockroachDB as follows:

  • PostgreSQL types are mapped to existing CockroachDB types that have the same OID.
  • The following MySQL types are mapped to corresponding CockroachDB types:

    MySQL type CockroachDB type Notes
    CHAR, CHARACTER, VARCHAR, NCHAR, NVARCHAR VARCHAR Varying-length string; raises warning if BYTE semantics used
    TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT STRING Unlimited-length string
    GEOMETRY GEOMETRY Spatial type (PostGIS-style)
    LINESTRING LINESTRING Spatial type (PostGIS-style)
    POINT POINT Spatial type (PostGIS-style)
    POLYGON POLYGON Spatial type (PostGIS-style)
    MULTIPOINT MULTIPOINT Spatial type (PostGIS-style)
    MULTILINESTRING MULTILINESTRING Spatial type (PostGIS-style)
    MULTIPOLYGON MULTIPOLYGON Spatial type (PostGIS-style)
    GEOMETRYCOLLECTION, GEOMCOLLECTION GEOMETRYCOLLECTION Spatial type (PostGIS-style)
    JSON JSONB CRDB's native JSON format
    TINYINT, INT1 INT2 2-byte integer
    BLOB BYTES Binary data
    SMALLINT, INT2 INT2 2-byte integer
    MEDIUMINT, INT, INTEGER, INT4 INT4 4-byte integer
    BIGINT, INT8 INT 8-byte integer
    FLOAT FLOAT4 32-bit float
    DOUBLE FLOAT 64-bit float
    DECIMAL, NUMERIC, REAL DECIMAL Validates scale ≤ precision; warns if precision > 19
    BINARY, VARBINARY BYTES Binary data
    DATETIME TIMESTAMP Date and time (no time zone)
    TIMESTAMP TIMESTAMPTZ Date and time with time zone
    TIME TIME Time of day (no date)
    BIT VARBIT Variable-length bit array
    DATE DATE Date only (no time)
    TINYBLOB, MEDIUMBLOB, LONGBLOB BYTES Binary data
    BOOL, BOOLEAN BOOL Boolean
  • The following Oracle types are mapped to CockroachDB types:

    Oracle type(s) CockroachDB type Notes
    NCHAR, CHAR, CHARACTER CHAR(n) or CHAR Fixed-length character; falls back to unbounded if length not specified
    VARCHAR, VARCHAR2, NVARCHAR2 VARCHAR(n) or VARCHAR Varying-length string; raises warning if BYTE semantics used
    STRING STRING Unlimited-length string
    SMALLINT INT2 2-byte integer
    INTEGER, INT, SIMPLE_INTEGER INT4 4-byte integer
    LONG INT8 8-byte integer
    FLOAT, BINARY_FLOAT, REAL FLOAT4 32-bit float
    DOUBLE, BINARY_DOUBLE FLOAT8 64-bit float
    DEC, NUMBER, DECIMAL, NUMERIC DECIMAL(p, s) or DECIMAL Validates scale ≤ precision; warns if precision > 19
    DATE DATE Date only (no time)
    BLOB, RAW, LONG RAW BYTES Binary data
    JSON JSONB CRDB's native JSON format
    CLOB, NCLOB STRING Treated as large text
    BOOLEAN BOOL Boolean
    TIMESTAMP TIMESTAMP or TIMESTAMPTZ If WITH TIME ZONETIMESTAMPTZ, else TIMESTAMP
    ROWID, UROWID STRING Treated as opaque identifier
    SDO_GEOMETRY GEOMETRY Spatial type (PostGIS-style)
    XMLTYPE STRING Stored as text

See also

×