SQL语法详解与练习试题及答案
姓名:____________________
一、单项选择题(每题2分,共10题)
1.下列哪个SQL语句用于创建一个名为“students”的表,包含“id”和“name”两个字段?
A.CREATETABLEstudents(idINT,nameVARCHAR(100));
B.CREATETABLEstudents(idINT,nameTEXT);
C.CREATETABLEstudents(idINT,nameCHAR(100));
D.CREATETABLEstudents(idINT,nameBLOB);
2.下列哪个SQL语句用于删除名为“students”的表?
A.DROPTABLEstudents;
B.DELETETABLEstudents;
C.DELETEFROMstudents;
D.TRUNCATETABLEstudents;
3.在SQL中,使用“ALTERTABLE”语句可以做什么?
A.添加、删除或修改表中的字段;
B.添加、删除或修改表中的索引;
C.添加、删除或修改表中的约束;
D.以上都是;
4.下列哪个SQL语句用于查询“students”表中所有学生的姓名?
A.SELECTnameFROMstudents;
B.SELECT*FROMstudentsWHEREname;
C.SELECTnameWHEREstudents;
D.SELECTnameFROMstudentsWHEREnameISNOTNULL;
5.下列哪个SQL语句用于更新“students”表中名为“John”的学生的姓名为“Jack”?
A.UPDATEstudentsSETname=JackWHEREname=John;
B.UPDATEstudentsSETname=JackWHEREname=John;
C.UPDATEstudentsSETname=JackWHEREname=John;
D.UPDATEstudentsSETname=JackWHEREname=John;
6.下列哪个SQL语句用于插入一条新记录到“students”表中?
A.INSERTINTOstudents(id,name)VALUES(1,Alice);
B.INSERTINTOstudents(id,name)VALUES(Alice,1);
C.INSERTINTOstudents(name,id)VALUES(Alice,1);
D.INSERTINTOstudents(name,id)VALUES(Alice,1);
7.下列哪个SQL语句用于删除“students”表中所有学生的记录?
A.DELETEFROMstudents;
B.DELETEstudents;
C.TRUNCATETABLEstudents;
D.DROPTABLEstudents;
8.下列哪个SQL语句用于查询“students”表中年龄大于20岁的学生姓名?
A.SELECTnameFROMstudentsWHEREage20;
B.SELECTnameFROMstudentsWHEREage20;
C.SELECTnameFROMstudentsWHEREage20;
D.SELECTnameFROMstudentsWHEREage20;
9.下列哪个SQL语句用于查询“students”表中姓名以字母“A”开头的所有学生姓名?
A.SELECTnameFROMstudentsWHEREnameLIKEA%;
B.SELECTnameFROMstudentsWHEREnameLIKEA;
C.SELECTnameFROMstudentsWHEREnameLIKE%A%;
D.SELECTnameFROMstudentsWHEREnameLIKEA%;
10.下列哪个SQL语句用于查询“students”表中姓名为“John”或“Jack”的学生姓名?
A.SELECTnameFROMstudentsWHEREnameIN(John,Jack);
B.SELECTnameFROMstudentsWHEREnameIN(John,Jack);
C.SEL