文章目录

  • 二维表修改表结构
  • 增加字段
  • 修改字段
  • 删除字段
  • 修改表名


二维表修改表结构

一般都是在项目初期会进行数据库表字段的增减操作,而在项目后期对字段的操作都会引起程序的大部分变动。

增加字段

语法:alter table 表名 add 字段名 类型
alter table student add sphone number(11);

修改字段

  1. 修改字段名
语法:alter table student modify 字段名 新的类型
 alter table student modify sphone varchar2(11);
  1. 修改字段类型
语法:alter table 表名 rename column 旧字段名 to 新字段名
 alter table student  rename column sphone to "手机号";

删除字段

语法 alter table 表名 drop column 字段名。
alter table student drop column "手机号";

修改表名

语法:rename 原有表名 to 新的表名
rename student to student2;