oracle表字段的增加删除和修改

本文详细介绍了如何在Oracle数据库中进行表结构的变更操作,包括字段的增加、删除、修改长度与类型,以及字段和表名称的重命名等实用技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

oracle表字段的增加删除和修改
--增加字段
alter table luffy.student_test2 add (CDR_CONTENT      VARCHAR2(2000));
alter table luffy.student_test2 add (COURSE_INST_ID      NUMBER(12));
alter table luffy.student_test2 add ADDRESS VARCHAR2(40);


--删除字段
alter table luffy.student_test2 drop column CDR_CONTENT;
alter table luffy.student_test2 drop column PROD_INST_ID;
alter table luffy.student_test2 drop column ADDRESS ;


--修改字段长度和类型
alter table luffy.student_test2 modify(id number(7));--将字段长度改为7
alter table luffy.student_test2 modify id number(20);--将字段长度改为20


alter table luffy.student_test2 modify(id varchar2(8));--将字段类型由number改为varchar2,长度为8,(要更改类型,需要修改的列必须为空)
alter table luffy.student_test2 modify id varchar2(20);--将字段类型由number改为varchar2,长度为20,(要更改类型,需要修改的列必须为空)


--修改字段名称
alter table luffy.student_test2 rename column id to stu_id;
alter table luffy.student_test2 rename column stu_id to id;


--修改表名称
alter table luffy.student_test2 rename to student_test22;--修改表名 
rename luffy.student_test22 to student_test2; --不允许指定表的所属用户


--查询某用户下所有的表
select * from dba_tables where owner='ESB_TEST';




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值