- 最后登录
- 2014-8-21
- 在线时间
- 26 小时
- 威望
- 47
- 金钱
- 186
- 注册时间
- 2011-12-21
- 阅读权限
- 10
- 帖子
- 34
- 精华
- 0
- 积分
- 47
- UID
- 117
|
1#
发表于 2012-4-16 15:41:25
|
查看: 6465 |
回复: 5
最新看了Oracle 11g增加列,并带默认值的新特性,还是有很多疑问,SQL REFERENCE中写到
If you specify the DEFAULT clause for a NOT NULL column, then the default value is stored as metadata but the column itself is not populated with data. However, subsequent queries that specify the new column are rewritten so that the default value is returned in the result set.
而
If you specify the DEFAULT clause for a nullable column, then the default value is added to existing rows as part of this ALTER TABLE statement, and any update triggers defined on the table are fired. This behavior also results if you change a NOT NULL column with a default value to be nullable.
这是不是就是说,如果我有一张表:
select * from test2;
ID
----------
1
2
3
那么当我添加:
alter table test add(b number default 10 );
此时默认还是会更新所有的行数据
而
alter table test add(b number default 10 not null);
仅仅是讲10写到col$基表中之前的数据是不会更新的。
不知道理解是否有问题
|
|