OCP-1Z0-051 补充题库 第2题 添加外键FOREIGN KEY

一、原题
You need to design a student registration database that contains several tables storing academic
information.
The STUDENTS table stores information about a student. The STUDENT_GRADES table stores
information about the student's grades. Both of the tables have a column named STUDENT_ID.
The STUDENT_ID column in the STUDENTS table is a primary key.
You need to create a foreign key on the STUDENT_ID column of the STUDENT_GRADES table
that points to the STUDENT_ID column of the STUDENTS table. Which statement creates the
foreign key?
A.
CREATE TABLE student_grades (student_id NUMBER(12),
                             semester_end DATE,
                             gpa NUMBER(4,3),
                             CONSTRAINT student_id_fk REFERENCES (student_id) FOREIGN KEY students(student_id));
B.
CREATE TABLE student_grades(student_id NUMBER(12),
                            semester_end DATE,
                            gpa NUMBER(4,3),
                            student_id_fk FOREIGN KEY (student_id) REFERENCES students(student_id));
C.
 CREATE TABLE student_grades(student_id NUMBER(12),
                             semester_end DATE,
                             gpa NUMBER(4,3),
                             CONSTRAINT FOREIGN KEY (student_id) REFERENCES students(student_id));
D.
CREATE TABLE student_grades(student_id NUMBER(12),
                             semester_end DATE,
                             gpa NUMBER(4,3),
                             CONSTRAINT student_id_fk FOREIGN KEY (student_id) REFERENCES students(student_id));



答案: D

二、题目翻译
要设计一个包含几个表的存储大学生注册信息的数据库。
STUDENTS表保存学生信息,STUDENT_GRADES表保存学生的成绩信息,这两张表都有一列STUDENT_ID,STUDENTS表中的STUDENT_ID列是主键。
现在要在STUDENT_GRADES表上建一个STUDENT_ID列的外键,下面哪个是建外键的语句?

三、题目解析
这个就是语法问题,查一下语法图,就可以了。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值