All pages
Powered by GitBook
1 of 1

Loading...

Silent Column Changes

Explore Silent Column Changes in MariaDB. Learn when the server automatically modifies column definitions or data types during table creation to ensure engine compatibility.

When a CREATE TABLE or ALTER TABLE command is issued, MariaDB silently changes a column specification in the following cases:

  • PRIMARY KEY columns are always NOT NULL.

  • Any trailing spaces from SET and ENUM values are discarded.

  • TIMESTAMP columns are always NOT NULL, and display sizes are discarded.

  • A row-size limit of 65535 bytes applies.

  • If is not enabled (by default, it is), a column longer than 65535 become , and a columns longer than 65535 becomes a . If strict mode is enabled the silent changes will not be made, and an error will occur.

  • If a USING clause specifies an index that's not permitted by the storage engine, the engine will instead use another available index type that can be applied without affecting results.

  • If the CHARACTER SET binary attribute is specified, the column is created as the matching binary data type. A TEXT becomes a BLOB, CHAR a BINARY and VARCHAR a VARBINARY. ENUMs and SETs are created as defined.

To ease imports from other RDBMSs, MariaDB also silently maps the following data types:

Other Vendor Type
MariaDB Type

Currently, all MySQL types are supported in MariaDB.

For type mapping between Cassandra and MariaDB, see .

Example

Silent changes in action:

This page is licensed: CC BY-SA / Gnu FDL

INT1

INT2

INT3

INT4

INT8

LONG VARBINARY

LONG VARCHAR

LONG

MIDDLEINT

NUMERIC

BOOL

TINYINT

BOOLEAN

TINYINT

CHARACTER VARYING(M)

VARCHAR(M)

FIXED

DECIMAL

FLOAT4

FLOAT

FLOAT8

DOUBLE

strict SQL mode
VARCHAR
TEXT
VARBINARY
BLOB
Cassandra storage engine
CREATE TABLE SilenceIsGolden
   (
    f1 TEXT CHARACTER SET BINARY,
    f2 VARCHAR(15) CHARACTER SET BINARY,
    f3 CHAR CHARACTER SET BINARY,
    f4 ENUM('x','y','z') CHARACTER SET BINARY,
    f5 VARCHAR (65536),
    f6 VARBINARY (65536),
    f7 INT1
   );
Query OK, 0 rows affected, 2 warnings (0.31 sec)

SHOW WARNINGS;
+-------+------+-----------------------------------------------+
| Level | Code | Message                                       |
+-------+------+-----------------------------------------------+
| Note  | 1246 | Converting column 'f5' from VARCHAR to TEXT   |
| Note  | 1246 | Converting column 'f6' from VARBINARY to BLOB |
+-------+------+-----------------------------------------------+

DESCRIBE SilenceIsGolden;
+-------+-------------------+------+-----+---------+-------+
| Field | Type              | Null | Key | Default | Extra |
+-------+-------------------+------+-----+---------+-------+
| f1    | blob              | YES  |     | NULL    |       |
| f2    | varbinary(15)     | YES  |     | NULL    |       |
| f3    | binary(1)         | YES  |     | NULL    |       |
| f4    | enum('x','y','z') | YES  |     | NULL    |       |
| f5    | mediumtext        | YES  |     | NULL    |       |
| f6    | mediumblob        | YES  |     | NULL    |       |
| f7    | tinyint(4)        | YES  |     | NULL    |       |
+-------+-------------------+------+-----+---------+-------+
TINYINT
SMALLINT
MEDIUMINT
INT
BIGINT
MEDIUMBLOB
MEDIUMTEXT
MEDIUMTEXT
MEDIUMINT
DECIMAL