SQL> create table test(id int,age int);//创建表
Table created.
SQL> insert into test
values(1,10);
//填充数据
1 row created.
SQL> insert into test values(2,20);
1 row created.
SQL> select * from
test;
//实验前,表的内容
ID
AGE
---------- ----------
1
10
2
20
SQL> alter table
test
//添加一列name,并设置默认值为'I love oracle'
2 add name varchar(20) default
'I love oracle';
Table altered.
SQL> select * from
test;
//可以看到,设置过后,表中前两行不仅多了一列name,
//而且值也被设置成了'I love oracle'
ID
AGE NAME
---------- ---------- --------------------
1
10 I love oracle
2
20 I love oracle
SQL> alter table
test
//再添加一列city
2 add city char(10);
Table altered.
SQL> select * from test;
ID
AGE
NAME
CITY
---------- ---------- -------------------- ----------
1
10 I love oracle