2、统计档案表中学生来自多少个城市,下面sql语句正确的是 a、selcet sum(distinct 家庭住址) from 档案表 b、selcet distinct 家庭住址 from 档案表 c、selcet count(家庭住址) from 档案表 d、selcet count(distinct 家庭住址) from 档案表
3、信贷额度关系credit-in(c_name,limit,credit_balance)中的三个属性分别表示用户姓名、信贷额度和到目前为止的花费。下表为关系credit-in的一个具体实例。若要查询每个用户还能花费多少,相应的sql语句应为:select() from credit-in。 a、c_name,credit balance-limit b、c_name,limit-credit_balance c、c_name,limit,credit_balance d、c_name,credit_balance
1、商品关系p(商品名,条形码,产地,价格),将价格小于50的商品上调5%的sql语句应该是: update p ( ) where价格<50; a、set价格=‘价格*1.05’ b、set价格=价格*1.05 c、modify价格=‘价格*1.05’ d、modify价格=价格*1.05
2、mysql中,insert语句不能完成一次性向表中插入多条记录。
3、更新操作的关键字是update
单元3测验
1、信贷额度关系credit-in(c_name,limit,credit_balance)中的三个属性分别表示用户姓名、信贷额度和到目前为止的花费。若要查询每个用户还能花费多少,相应的sql语句应为:select ( ) from credit-in。 a、c_name,credit balance-limit b、c_name,limit-credit_balance c、c_name,limit,credit_balance d、c_name,credit_balance
2、设有关系students(学号,姓名,年龄,性别,系名,家庭住址),如果要查询姓“李”的且家庭住址包含“科技路”的学生学号、姓名以及所在系,则对应的select语句如下: select 学号,姓名,系名 from students where 姓名 like '李%' and ( ); a、家庭住址like '%科技路%' b、家庭住址 like '*科技路*' c、家庭住址as '%科技路%' d、家庭住址 as '*科技路*'
3、商品关系p(商品名,条形码,产地,价格)中的条形码可以作为该关系的主键。查询由“北京”生产的185升电冰箱的sql语句应该是: select 商品名,产地 from p where 产地=‘北京’and ( ); a、条形码=185升电冰箱 b、条形码=‘185升电冰箱’ c、商品名=185升电冰箱 d、商品名=‘185升电冰箱’
4、学生关系模式为s(sno, sname, sd, sage),其中:sno表示学生学号,sname表示学生姓名,sd表示学生所在系,sage表示学生年龄。试将下面的sql语句空缺部分补充完整,使其可以查询计算机系学生的学号、姓名和年龄。 select sno,sname,sage from s where ( ); a、sd=计算机 b、sd=′计算机′ c、′sd′=计算机 d、′sd=计算机′
5、设有关系student(学号,姓名,年龄,性别,系名),如果要查询姓名至少包括5个字母,且倒数第二个字母为“g”的学生的学号、姓名以及所在系,则对应的select语句如下: select 学号,姓名,系名 from students where 姓名 like ( ); a、"_ _ _g_%" b、"_ _ _%g_" c、姓名 d、."_ _ _g%"
7、设有一个关系emp(职工号,姓名,部门名,工种,工资),若需查询不同部门中担任“钳工”的职工的平均工资,则相应的selcect语句为: selcet部门名,avg(工资) as 平均工资 from emp group by ( ) having 工种=‘钳工’; a、职工号 b、姓名 c、部门名 d、工种
8、有学生表s、课程表c和选课表sc,结构分别如下: s(学号, 姓名, 性别, 年龄) c(课程号, 课程名, 学分) sc(学号, 课程号, 成绩) 检索学号、姓名、学生所修课程的课程名和成绩,正确的sql语句是( )。 a、select 学号, 姓名, 课程名, 成绩 from s, c, sc where s.学号=sc.学号 and sc.学号=c.学号; b、select 学号, 姓名, 课程名, 成绩 from s inner join sc on s.学号=sc.学号 inner join c on sc.课程号=c.课程号; c、select s.学号, 姓名, 课程名, 成绩 from s inner join sc inner join c on s.学号=sc.学号 on sc.课程号=c.课程号; d、select s.学号, 姓名, 课程名, 成绩 from s inner join sc on s.学号=sc.学号 inner join c on sc.课程号=c.课程号;
10、有如下三个数据库表: 图书(索书号, 书名, 出版社, 定价, isbn) 借书证(借书证号, 姓名, 性别, 专业, 所在单位) 借书记录(借阅号, 索书号, 借书证号, 借书日期, 还书日期) 查询2018年被借过的图书书名、出版社和借书日期,正确的sql语句是( )。 a、select a.书名, a.出版社, b.借书日期 from 图书 a inner join 借书记录 b on a.索书号=b.索书号 where b.借书日期=2018; b、select a.书名, a.出版社, b.借书日期 from 图书 a inner join 借书记录 b on a.索书号=b.索书号 where b.借书日期=year(2018); c、select a.书名, a.出版社, b.借书日期 from 图书 a inner join 借书记录 b on a.索书号=b.索书号 where year(b.借书日期)=2018; d、select a.书名, a.出版社, b.借书日期 from 图书 a inner join 借书记录 b on a.索书号=b.索书号 where year(b.借书日期)=year(2018);
11、在成绩表中,查询数学成绩最好的三名学生的学生姓名,正确的语句是( )。 a、select 姓名 from 成绩表 order by 数学 desc limit 1, 3; b、select 姓名 from 成绩表 order by 数学 desc limit 1, 2; c、select 姓名 from 成绩表 order by 数学 desc limit 0, 3; d、select 姓名 from 成绩表 order by 数学 desc limit 0, 2;
12、查询1997,1999年出生的同学信息,正确的select语句是( )。 a、select * from student where year(birthday) not in(1997, 1999); b、select * from student where year(birthday)=1997 and year(birthday)=1999; c、select * from student where year(birthday) in(1997, 1999); d、select * from student where year(birthday) exists(1997, 1999);
13、统计档案表中学生来自多少个城市,下面sql语句正确的是( )。 a、select sum(distinct 家庭住址) from 档案表; b、select distinct 家庭住址 from 档案表; c、select count(家庭住址) from 档案表; d、select count(distinct 家庭住址) from 档案表;
14、学生表student包含sname、sex、age三个属性列,其中age的默认值是20,执行如下sql语句的结果是( ): insert into student(sex,sname,age) values('m','lili'); a、执行成功,sname,sex,age的值分别是lili,m,20 b、执行成功,sname,sex,age的值分别是m,lili,20 c、sql语句不正确,执行失败 d、执行成功,sname,sex,age的值分别是m,lili,null
15、先按学号升序排列,再按成绩降序排列检索出选课表中的所有信息,下面sql语句正确的是( )。 a、select * from 选课表 order by 学号, 成绩; b、select * from 选课表 group by 学号, 成绩; c、select * from 选课表 order by 学号, 成绩 desc; d、select * from 选课表 order by 学号 desc, 成绩;
16、与where dno in ('im', 'cs')条件等价的查询表达式是( )。 a、where dno between 'im' or 'cs' b、where dno between 'im' and 'cs' c、where dno='im' or dno='cs' d、where dno='im' and dno='cs'
17、在成绩表中,查找数学分数最高的学生记录,下列sql语句的空白区应填入的是( )。 select * from 成绩 where 数学>=( )(select 数学 from 成绩表) a、some b、exists c、any d、all
19、在教师表中查找“工龄”还没有输入数据的记录,使用的sql语句是( )。 a、select * from 教师表 where 工龄 is not null; b、select * from 教师表 where 工龄=0; c、select * from 教师表 where 工龄 is null; d、select * from 教师表 where 工龄=null;
4、删除触发器trigger_fg1的语句是( ) a、drop trigger trigger_fg1 b、alter trigger trigger_fg1 c、drop * from trigger_fg1 d、select * from t_reader where drop trigger_fg1
9、在以下语句段中,变量 b的取值可能是( ) declare b char(3); case a when 1 then set b = '一月'; when 2 then set b = '二月'; else set b='参数错'; end case; a、"参数错" b、"一月" c、"二月" d、null
5、先按学号升序排列,再按成绩降序排列检索出选课表中的所有信息,下面sql语句正确的是( )。 a、select * from 选课表 order by 学号, 成绩 b、select * from 选课表 group by 学号, 成绩 c、select * from 选课表 order by 学号, 成绩 desc d、select * from 选课表 order by 学号 desc, 成绩
6、在教师表中查找“工龄”还没有输入数据的记录,使用的sql语句是( )。 a、select * from 教师表 where 工龄 is not null; b、select * from 教师表 where 工龄=null; c、select * from 教师表 where 工龄=0; d、select * from 教师表 where 工龄 is null;
7、以下哪一个关键字是用来创建唯一索引的。 a、uniuqe index b、fulltext index c、index d、create index
11、与where dno in ('im', 'cs')条件等价的查询表达式是( )。 a、where dno between 'im' or 'cs' b、where dno between 'im' and 'cs' c、where dno='im' or dno='cs' d、where dno='im' and dno='cs'
12、信贷额度关系credit-in(c_name,limit,credit_balance)中的三个属性分别表示用户姓名、信贷额度和到目前为止的花费。若要查询每个用户还能花费多少,相应的sql语句应为:select ( ) from credit-in。 a、c_name,credit balance-limit b、c_name,limit-credit_balance c、c_name,limit,credit_balance d、c_name,credit_balance
13、商品关系p(商品名,条形码,产地,价格)中的条形码可以作为该关系的主键。查询由“北京”生产的185升电冰箱的sql语句应该是: select 商品名,产地 from p where 产地=‘北京’and ( ); a、条形码=185升电冰箱 b、条形码=‘185升电冰箱’ c、商品名=185升电冰箱 d、商品名=‘185升电冰箱’
14、在成绩表中,查找数学分数最高的学生记录,下列sql语句的空白区应填入的是( )。 select * from 成绩 where 数学>=( )(select 数学 from 成绩表) a、some b、exists c、any d、all