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

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

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

    alter table student add primary key(student_id)

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

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

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

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

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

      alter table student modify(sex default'女')

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

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



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值