alter table test add (d number DEFAULT 0) ;
这个操作是对该表 现存的所有的列都添加一个列,并且将新添的这个列更新为default的值。
所以该操作不能在线执行,会锁表。
上面的操作相当于
alter table add(d number)
alter table modify(d number default 30);
update table set d=30 where d is null;
而下面的操作
alter table table_name add col_name data_type;
atler table table_name modify col_name default default_value;
只对以后新的数据有效!之前的都为null
这个操作瞬间可以完成
Popularity: 29% [?]
