找回密码
 注册
搜索
热搜: 回贴

Oracle alter table

2010-1-30 22:18| 发布者: admin| 查看: 31| 评论: 0|原作者: 冰淇淋

alter table 的功能
create table test(a varchar2(20),b number(2))
重名命
alter table test rename to test1
(rename test1 to test2)

增删字段


alter table test2 drop column f
修改字段类型和大小
alter table test2 modify d varchar(40)
alter table test2 modify f varchar(40)

alter table test2 add c varchar2(30)
alter table test2 add (d varchar2(30),e number(4))
alter table test2 rename column e to f
处理约束
alter table test2 add constraint pk_mypri primary key (d,f)
利用下面的语句在删除DEPT表中的PRIMARY KEY约束时,同时将删除其它表中引用这个约束的FOREIGN KEY约束:
alter table dept drop primary key cascade
加foreign key约束(多字段/表级)
alter table employees add constraint emp_jobs_fk foreign key (job,deptno) references jobs (jobid,deptno) on delete cascade


最新评论

相关分类

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-10-1 07:44 , Processed in 0.119978 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部