SQL向基本表中增加一个新列后,原有元组在该列上的值是否是空值?

如题所述

默认是空的。


除非你这个新加的列,  是  NOT  NULL ,  并且设置了  DEFAULT


例子代码如下:


mysql> create table test11(id int);
Query OK, 0 rows affected (0.01 sec)
mysql> insert into test11 values(100);
Query OK, 1 row affected (0.00 sec)
mysql> ALTER TABLE test11 ADD name varchar(10) not null default 'ABC';
Query OK, 1 row affected (0.02 sec)
Records: 1  Duplicates: 0  Warnings: 0
mysql> select * from test11;
+------+------+
| id   | name |
+------+------+
|  100 | ABC  |
+------+------+
1 row in set (0.00 sec)

温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-05-12
是的,即使你设了默认值
相似回答