Returns the default value for a table column. If the column has no default value,
NULL is returned. For integer columns using
0 is returned.
DEFAULT as a value to set in an
UPDATE statement, you can use the bare keyword
DEFAULT without the parentheses and argument to refer to the column in context. You can only use
DEFAULT as a bare keyword if you are using it alone without a surrounding expression or function.
Select only non-default values for a column:
SELECT i FROM t WHERE i != DEFAULT(i);
Update values to be one greater than the default value:
UPDATE t SET i = DEFAULT(i)+1 WHERE i < 100;
When referring to the default value exactly in
INSERT, you can omit the argument:
INSERT INTO t (i) VALUES (DEFAULT); UPDATE t SET i = DEFAULT WHERE i < 100;
© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.