DEFAULT
Declaration
DEFAULT(col_name)
Description
Returns the default value of the specified column. If the column does not have a default value, it returns NULL.
Examples
CREATE TABLE t1 (id int,i int DEFAULT 1);
Query OK, 0 rows affected
INSERT INTO t1 VALUES (1,3);
Query OK, 1 row affected
UPDATE t1 SET i = DEFAULT(i)+1 WHERE id < 100;
Query OK, 1 row affected
Rows matched: 1 Changed: 1 Warnings: 0
SELECT * FROM t;
+------+------+
| id | i |
+------+------+
| 1 | 2 |
+------+------+
1 row in set (0.001 sec)
CREATE TABLE t2 (id int,i int);
Query OK, 0 rows affected
INSERT INTO t2 VALUES (1,3);
Query OK, 1 row affected
UPDATE t2 SET i = DEFAULT(i)+1 WHERE id < 100;
SELECT * FROM t2;
+------+------+
| id | i |
+------+------+
| 1 | NULL |
+------+------+
1 row in set (0.001 sec)