oracle 数据库 alter table 修改字段
– 更新表名(很少用)
alter table tablename RENAME TO newtablename;
– 添加字段语法:
alter table tablename add (column datatype [default value][null/not null]);
– 修改字段语法:
alter table tablename modify (column datatype [default value][null/not null]);
– 删除字段的语法:
alter table tablename drop (column);
-- 修改表名
alter table USERS2 RENAME TO USERS;
-- 添加字符形字段
alter table USERS add (testString varchar2(30) default '' null);
-- 添加number类型字段,且不为空
alter table USERS add (testInt number(3,0) default 0 not null);
-- 修改列名字
alter table USERS rename column testInt to testInt2;
-- 修改列类型
alter table USERS modify (testInt2 number(5,0) default 0 null);
-- 删除字段
alter table USERS drop column testInt2;