Oracle【二维表的维护】

二维表的维护

--添加新的字段:alter table 表名 add 字段名 类型  [一般不加约束条件]
alter table student add sphone number(11)

原表:

新增字段后的表:

修改原有的字段:【修改字段类型、修改字段名、删除字段】

1 --修改字段类型:alter table 表名 modify 字段名 新类型
2 alter table student modify sphone varchar(11)
3 --修改字段名:alter table 表名 rename column 字段名 to 新字段名
4 alter table student rename column sphone to phone
5 --删除字段:alter table 表名 column 字段名 
6 alter table student drop column phone

表的修改和删除

1 --修改表名:rename 原表名 to 新表名
2 rename student to student2
3 --删除表:drop table 表名
4 drop table student

查看表结构:desc 表名[命令窗口]: desc student; 


  一般这些操作在实际中运用的很少,在建表的初期都基本设计好,不会有太大的改动。都是增删改查操作比较平凡,这些操作一般也都是用图形界面化工具去管理操作,使用起来方便,不至于命令出错而导致一系列不必要的麻烦。了解即可。

原文地址:https://www.cnblogs.com/cao-yin/p/9782818.html