1.添加字段的语法:
alter table tablename add (column datatype [default value][null/not null],….);
事例:
------添加字段-----
alter table test1
add (name varchar2(30) default ‘无名氏’ not null);
------一次性添加多字段-----
alter table test1
add (name varchar2(30) default ‘无名氏’ not null,
age integer default 22 not null,
has_money number(9,2));
2.修改字段的语法:
alter table tablename modify (column datatype [default value][null/not null],….);
事例:
-------修改一个字段-------
alter table test1
modify (name varchar2(16) default ‘unknown’);
ps:比较正规的方式
alter table TABLE_NAME rename column FIELD_NAME to NEW_FIELD_NAME;
3.删除字段的语法:
alter table tablename drop (column);
事例:
alter table test1
drop column name;