当前位置: 移动技术网 > IT编程>数据库>Oracle > oracle关于约束与alter的入门操作讲解(2)

oracle关于约束与alter的入门操作讲解(2)

2018年10月05日  | 移动技术网IT编程  | 我要评论

接着入门1生成的表 studnet,teacher,test_course,score

将student表中的student_id设置为“主键”

alter table student add primary key(student_id)

设置外键:test_score表中的student_id参照student表中的student_id,test_id参照test表中的test_id;、

alter table test_score add constraint fk_sid foreign key(studnet_id) references studnet(studnet_id)

在student表中添加专业列institute,最长是10个汉字,不允许为空,默认值为“计算机软件”;

alter table student add institute char(10) not null default 'cs'

修改student表中列sex上的默认值为‘女’;

alter table student modify(sex default'女')

在teacher表中添加约束,工作时间必须大于生日;

alter table teacher add constraints ck_date check(workdata>birthdata)

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网