資料庫兩題 - 考試

Table of Contents

某年雲科大資管所考題

1. A SQL SELECT statement contains a nested query in the WHERE clause,comparing

the value of an attribute to the values returned by the nested SELECT with an

IN predicate. Which of the following predicates can be used in that statement

instead of IN?

(A)=SOME (B)=ALL

(C)=ANY (D)=EVERY

答案是C

查了一下用法IN=ANY=SOME

所以不選SOME的理由是 還是答案其實可以選

2. Two tables are given: STUDENT(StudNO,Name,Department) and GRADES(StudNo,
Course,Grade). Which of the given SQL statements will retrieve the names
of
students who got an A in each course they passed?
(A) SELECT name
FROM student
WHERE NOT EXISTS(SELECT *
FROM grades
WHERE grade IN('B','C')and
student.studno=grades.studno);
(B) SELECT name
FROM student JOIN grades ON student.studno=grades.studno
WHERE grade='A';
(C) SELECT name
FROM student,grades
WHERE grade='A'and student.studno=grades.studno;
(D) SELECT name
FROM student
WHERE 'A'=ALL(SELECT grade
FROM grades
WHERE student.studno=grades.studno);
已知題目沒有提到等第有哪些 所以不考慮A
由於grades的屬性沒有name 所以C也不考慮
B跟D不知道差在哪 答案是D 可是不知道B錯在哪

--

All Comments

Lauren avatarLauren2013-06-13
請用[考題]標題分類附上出處 置底文有修改標題教學 感謝