SQL的基本操作及常用示例试题及答案
姓名:____________________
一、单项选择题(每题2分,共10题)
1.以下哪个SQL语句用于创建一个名为“Students”的表,包含字段“StudentID”和“Name”?
A.CREATETABLEStudents(StudentIDINT,NameVARCHAR(50))
B.CREATETABLEStudents(StudentIDINT,NameCHAR(50))
C.CREATETABLEStudents(StudentIDINT,NameTEXT)
D.CREATETABLEStudents(StudentIDINT,NameDATE)
2.以下哪个SQL语句用于删除名为“Students”的表?
A.DELETETABLEStudents
B.DROPTABLEStudents
C.TRUNCATETABLEStudents
D.DELETEFROMStudents
3.在SQL中,如何选择名为“Students”表中所有学生的姓名?
A.SELECTNameFROMStudents
B.SELECT*FROMStudentsWHEREName
C.SELECT*FROMStudentsWHERENameISNOTNULL
D.SELECTName,*FROMStudents
4.在SQL中,如何将“Students”表中“Name”字段的值更新为“John”?
A.UPDATEStudentsSETName=John
B.UPDATEStudentsWHEREName=John
C.UPDATEStudentsSETName=JohnWHEREName
D.UPDATEStudentsSETName=JohnWHEREName=John
5.在SQL中,以下哪个函数用于返回字符串的长度?
A.LEN()
B.LENGTH()
C.STR()
D.SUBSTRING()
6.在SQL中,如何连接两个字符串“Hello”和“World”?
A.CONCAT(Hello,World)
B.CONCAT(Hello,World)
C.Hello+World
D.Hello||World
7.在SQL中,以下哪个语句用于在“Students”表中插入一条新记录?
A.INSERTINTOStudents(StudentID,Name)VALUES(1,Alice)
B.INSERTINTOStudents(StudentID,Name)VALUES(Alice,1)
C.INSERTINTOStudentsVALUES(1,Alice)
D.INSERTINTOStudents(Alice,1)
8.在SQL中,以下哪个语句用于删除“Students”表中“StudentID”等于1的记录?
A.DELETEFROMStudentsWHEREStudentID=1
B.DELETEStudentsWHEREStudentID=1
C.DELETEFROMStudentsWHEREStudentID=1
D.DELETEStudentsWHEREStudentID=1
9.在SQL中,以下哪个语句用于创建一个名为“Courses”的表,包含字段“CourseID”和“Title”?
A.CREATETABLECourses(CourseIDINT,TitleVARCHAR(100))
B.CREATETABLECourses(CourseIDINT,TitleCHAR(100))
C.CREATETABLECourses(CourseIDINT,TitleTEXT)
D.CREATETABLECourses(CourseIDINT,TitleDATE)
10.在SQL中,以下哪个函数用于返回当前日期和时间?
A.GETDATE()
B.CURRENT_DATE()
C.NOW()
D.DATE_TIME()
二、多项选择题(每题3分,共10题)
1.以下哪些SQL语句可以用于查询“Students”表中所有学生的信息?
A.SELECT*FROMStudents
B.SELECTName,AgeFROMStudents
C.SELECT*FROMStu