create
table
test(a
varchar2
(
20
),b
number
(
2
))
重名命
alter
table
test rename
to
test1
(rename test1
to
test2)
alter
table
test2
add
(d
varchar2
(
30
),e
number
(
4
))
alter
table
test2 rename
column
e
to
f
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
增删字段
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 )
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
处理约束
alter table test2 add constraint pk_mypri primary key (d
,f
)
利用下面的语句在删除DEPT表中的PRIMARY KEY约束时,同时将删除其它表中引用这个约束的FOREIGN KEY约束:
alter table dept drop primary key cascade
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
alter table employees add constraint emp_jobs_fk foreign key (job,deptno) references jobs (jobid,deptno) on delete cascade