课堂小测验2:SQL (2026)

本测验总分18分,每题2分。请准确填写个人信息后完成作答,祝您答题顺利!
姓名
    ____________
学号
    ____________
A self-join resolves recursive relationships 自连接用于解决递归关系
对
错
An SQL statement containing an aggregate function must contain a GROUP BY clause. 包含聚合函数的 SQL 语句必须包含 GROUP BY 子句
对
错
A SELECT without a WHERE clause: 一个没有WHERE子句的SELECT:
A. Always outputs results to a log file 总是将结果输出到日志文件中
B. Results in an error message 导致错误消息
C. Selects all columns in the referencing table 选择所选表中的所有列
D. Lists only the definition of the table 仅列出表的定义
E. Selects all rows in the referencing table 选择所选表中的所有行
The relation is: Book(ISBN: string, Title: string, PublisherID: integer, Price: decimal) 关系是:Book(ISBN: 字符串, Title: 字符串, PublisherID: 整数, Price: 小数) Which of the following queries returns the publisher ID of the book whose ISBN is "97836"? 以下哪个查询返回 ISBN 为 “97836” 的书的出版商 ID?
A. select PublisherID from Book where ISBN = 97836;
B. return PublisherID from Book if ISBN = 97836;
C. select PublisherID, ISBN = 97836 from Book;
D. select ISBN from Book where PublisherID = 97836;
Given the relation: Student(StudentID: integer, Name: string, Cohort: string, Gender: string). 关系是:Student(StudentID: 整数, Name: 字符串, Cohort: 字符串, Gender: 字符串)。 Which of the following queries returns the list of cohorts (each cohort should list only once)? 以下哪个查询返回班级(cohorts)列表(每个班级只列出一次)?
A. select Cohort from Student;
B. select unique Cohort from Student;
C. select distinct Cohort from Student;
D. select * from Student;
Given the relation: Student(StudentID: integer, Name: string, Cohort: string, Gender: string). 关系是:Student(StudentID: 整数, Name: 字符串, Cohort: 字符串, Gender: 字符串)。 How many rows will the following query return? 以下查询将返回多少行? select Cohort, count(StudentID) from Student group by Cohort;
A. It depends on the total number of students in the table. 它取决于表中学生的总数。
B. It depends on the number of students in each cohort in the table. 它取决于表中每个班级的学生人数。
C. It depends on the number of distinct Cohort values in the table. 它取决于表中不同班级的数量。
The relation is: Student(StudentID: integer, Name: string, Cohort: string, Gender: string). 关系是:Student(StudentID: 整数, Name: 字符串, Cohort: 字符串, Gender: 字符串)。 Which of the following queries returns the student ID for all students whose name begins with "Sam"? 以下哪个查询返回所有名字以 “Sam” 开头的学生的学生 ID?
A. select StudentID from Student where Name = Sam%;
B. select StudentID from Student where Name = %Sam%;
C. select StudentID from Student where Name like %Sam%;
D. select StudentID from Student where Name like Sam%;
Given the relation: Student(StudentID: integer, Name: string, Cohort: string, Gender: string). Assume the Gender column takes either 'F' (female) or 'M' (male). 关系是:Student(StudentID: 整数, Name: 字符串, Cohort: 字符串, Gender: 字符串)。假设 Gender 列只有 ‘F’(女性)或 ‘M’(男性)。 Which of the following queries returns the number of female students for each cohort? 以下哪个查询返回每个班级(cohort)的女学生人数?
A. select Cohort, count(*) from Student where Gender = F group by Cohort;
B. select Gender, count(*) from Student group by Cohort having Gender = F;
C. select count(distinct Cohort) from Student where Gender = F;
D. select Cohort, Gender, count(*) from Student group by Cohort, Gender where Gender=F;
Consider the following three relations. They are about the relationship students taking courses. 

考虑以下三个关系。它们是关于学生选课的关系。 

Which of the following queries retrieves the names of students who take the course (ID) ‘CIS505’? 

以下哪个查询检索选修课程(ID)为“CIS505”的学生的姓名?

A. select Name from Student where StudentID in (select StudentID from Take where CourseID = CIS505);
B. select Name from Student where StudentID = (select StudentID from Take group by CourseID = CIS505);
C. select S.Name from Student S join Course C where C.CourseID = CIS505;
D. select S.Name from Student S inner join Take T on T.CourseID = CIS505;

11题 | 被引用0次

模板修改
使用此模板创建