OCP-1Z0-051-2015-2题
2015-04-20 10:45
274 查看
QUESTION NO: 2
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));
Answer: D
Explanation:
表STUDENTS 存放学生信息 ,列STUDENT_ID 是主键
表STUDENT_GRADES 存放学生年纪信息,和表STUDENTS 都有一个列STUDENT_ID
需要了解创建表 建立外键约束的格式
如果需要命名
FOREIGN KEY 约束,以及为多个列定义 FOREIGN KEY 约束,请使用下面的 SQL 语法:
CREATE TABLE student_grades(student_id NUMBER(12),
semester_end DATE, gpa NUMBER(4,3),
CONSTRAINT student_id_fk FOREIGN KEY (student_id) REFERENCE students(student_id));
如果需要命名 FOREIGN KEY 约束,以及添加 FOREIGN KEY 约束,请使用下面的 SQL 语法:
alter table student_grades
addCONSTRAINT
student_id_fk FOREIGN KEY (student_id) REFERENCE students(student_id));
如需撤销
FOREIGN KEY 约束,请使用下面的 SQL:
alter
table student_grades drop CONSTRAINT
student_id_fk
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));
Answer: D
Explanation:
表STUDENTS 存放学生信息 ,列STUDENT_ID 是主键
表STUDENT_GRADES 存放学生年纪信息,和表STUDENTS 都有一个列STUDENT_ID
需要了解创建表 建立外键约束的格式
如果需要命名
FOREIGN KEY 约束,以及为多个列定义 FOREIGN KEY 约束,请使用下面的 SQL 语法:
CREATE TABLE student_grades(student_id NUMBER(12),
semester_end DATE, gpa NUMBER(4,3),
CONSTRAINT student_id_fk FOREIGN KEY (student_id) REFERENCE students(student_id));
如果需要命名 FOREIGN KEY 约束,以及添加 FOREIGN KEY 约束,请使用下面的 SQL 语法:
alter table student_grades
addCONSTRAINT
student_id_fk FOREIGN KEY (student_id) REFERENCE students(student_id));
如需撤销
FOREIGN KEY 约束,请使用下面的 SQL:
alter
table student_grades drop CONSTRAINT
student_id_fk
相关文章推荐
- OCP-1Z0-051-2015-44题
- OCP-1Z0-051-2015-52题
- OCP-1Z0-051-2015-16题
- OCP-1Z0-051-2015-20题
- OCP-1Z0-051-2015-53题
- OCP-1Z0-051-2015-5题
- OCP-1Z0-051-2015-7题
- OCP-1Z0-051-2015-17题
- OCP-1Z0-051-2015-25题
- OCP-1Z0-051-2015-37题
- OCP-1Z0-051-2015-54题
- OCP-1Z0-051-2015-6题
- OCP-1Z0-051-2015-12题
- OCP-1Z0-051-2015-18题
- OCP-1Z0-051-2015-21题
- OCP-1Z0-051-2015-26题
- OCP-1Z0-051-2015-38题
- OCP-1Z0-051-2015-36题
- OCP-1Z0-051-2015-46题
- OCP-1Z0-051-2015-55题