mn_name, value [as type]]...); Adds or updates dynamic columns. * dyncol_blob must be either a valid dynamic columns blob (for example, COLUMN_CREATE returns such blob), or an empty string. column_name specifies the name of the column to be added. If dyncol_blob already has a column with this name, it will be overwritten. value specifies the new value for the column. Passing a NULL value will cause the column to be deleted. as type is optional. See #datatypes section for a discussion about types. The return value is a dynamic column blob after the modifications. Typical usage: -- MariaDB 5.3+: UPDATE tbl SET dyncol_blob=COLUMN_ADD(dyncol_blob, 1 /*column id*/, "value") WHERE id=1; -- MariaDB 10.0.1+: UPDATE t1 SET dyncol_blob=COLUMN_ADD(dyncol_blob, "column_name", "value") WHERE id=1; Note: COLUMN_ADD() is a regular function (just like CONCAT()), hence, in order to update the value in the table you have to use the UPDATE ... SET dynamic_col=COLUMN_ADD(dynamic_col, ....) pattern. COLUMN_GET ---------- COLUMN_GET(dyncol_blob, column_nr as type); COLUMN_GET(dyncol_blob, column_name as type); Get the value of a dynamic column by its name. If no column with the given name exists, NULL will be returned. column_name as type requires that one specify the datatype of the dynamic column they are reading. This may seem counter-intuitive: why would one need to specify which datatype they're retrieving? Can't the dynamic columns system figure the datatype from the data being stored? The answer is: SQL is a statically-typed language. The SQL interpreter needs to know the datatypes of all expressions before the query is run (for example, when one is using prepared statements and runs "select COLUMN_GET(...)", the prepared statement API requires the server to inform the client about the datatype of the column being read before the query is executed and the server can see what datatype the column actually has). See the Datatypes section for more information about datatypes. COLUMN_DELETE ------------- COLUMN_DELETE(dyncol_blob, column_nr, column_nr...); COLUMN_DELETE(dyncol_blob, column_name, column_name...); Delete a dynamic column with the specified name. Multiple names can be given. The return value is a dynamic column blob after the modification. COLUMN_EXISTS ------------- COLUMN_EXISTS(dyncol_blob, column_nr); COLUMN_EXISTS(dyncol_blob, column_name); Check if a column with name column_name exists in dyncol_blob. If yes, return 1, otherwise return 0. COLUMN_LIST ----------- COLUMN_LIST(dyncol_blob); Return a comma-separated list of column names. The names are quoted with backticks. SELECT column_list(column_create('col1','val1','col2','val2')); +---------------------------------------------------------+ | column_list(column_create('col1','val1','col2','val2')) | +---------------------------------------------------------+ | `col1`,`col2` | +---------------------------------------------------------+ COLUMN_CHECK ------------ COLUMN_CHECK(dyncol_blob); Check if dyncol_blob is a valid packed dynamic columns blob. Return value of 1 means the blob is valid, return value of 0 means it is not. Rationale: Normally, one works with valid dynamic column blobs. Functions like COLUMN_CREATE, COLUMN_ADD, COLUMN_DELETE always return valid dynamic column blobs. However, if a dynamic column blob is accidentally truncated, or transcoded from one character set to another, it will be corrupted. This function can be used to check if a value in a blob field is a valid dynamic column blob. Note: It is possible that a truncation cut a Dynamic Column "clearly" so that COLUMN_CHECK will not notice the corruption, but in any case of truncation a warning is issued during value storing. COLUMN_JSON ----------- COLUMN_JSON(dyncol_blob); Return a JSON representation of data in dyncol_blob. Example: SELECT item_name, COLUMN_JSON(dynamic_cols) FROM assets; +-----------------+----------------------------------------+ | item_name | COLUMN_JSON(dynamic_cols) | +----ÈÜ›ó