The Effect of ALTER TABLE on Null and Default Value Attributes
mysql>
mysql>
mysql> CREATE TABLE mytbl
-> (
-> j INT,
-> c CHAR(1)
-> );
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql>
mysql> ALTER TABLE mytbl MODIFY j INT NOT NULL DEFAULT 100;
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> SHOW COLUMNS FROM mytbl LIKE 'j';
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| j | int(11) | NO | | 100 | |
+-------+---------+------+-----+---------+-------+
1 row in set (0.00 sec)
mysql>
mysql> drop table mytbl;
Query OK, 0 rows affected (0.00 sec)
Related examples in the same category