Oracle 修改表 Alter Table...
--增加列
ALTER TABLE Student add sex number(2);
--删除列
ALTER TABLE Student drop column sex;
--更改列属性
ALTER TABLE Student modify city number(2);
--更改默认值
ALTER TABLE Student modify sex default 1;
--增加表主键
ALTER TABLE Student add constraint stu_pk primary key(student_id);
--增加表外键
ALTER TABLE Student add constraint stu_ref
foreign key(school) references school(schoolid);
--更改非空约束
ALTER TABLE Student modify sname not null;
--增加检查约束
ALTER TABLE Student add constraint check_stu_age check (age>10);
--增加唯一性
ALTER TABLE Student add constraint uqe_phone unique (phone);
--删除约束
ALTER TABLE Student drop constraint uqe_phone;
--约束失效
ALTER TABLE Student disable constraint uqe_phone;
--约束复效
ALTER TABLE Student enable constraint uqe_phone;
--修改表名
ALTER TABLE Student RENAME TO Student2
--修改表列名
ALTER TABLE Student RENAME COLUMN phone TO phoneno
--表备注 Add comments to the table
comment on table STUDENT
is '学生';
--字段备注 Add comments to the columns
comment on column STUDENT.sname
is '姓名';