首页 > 其他 > 详细

实施面试题(1)

时间:2021-03-30 00:25:05      阅读:34      评论:0      收藏:0      [点我收藏+]

下面哪个语句能实现从字符串‘Hello world’中取出‘ello world‘  D

A.select substr( ‘Hello World‘,1) from dual;

B.Select substr(trim( ‘Hello World‘,1,1))from dual;

C.select lower(substr(‘Hello World‘,1))from dual;

D. select lower(trim(‘H‘ from ‘Hello World‘))from dual;

2.只有满足联接条件的记录才包含在查询结果中,这种联接为  C

A.左联接 B、右联接 C内部联接 D、完全联接

3.查询订购单号(字符型,长度为4)尾字符是”1”的错误命  C

A.SELECT*FROM 订单 WHERE SUBSTR(订购单号,4)=”1”

B.SELECT * FROM订单 WHERE SUBSTR(订购单号,41)=”1”

C.SELECT * FROM 订单 WHERE “1”$订购单号0000000000

D.SELECT*FROM 订单 WHERE RIGHT(订购单号,1)=”1

4. 下列不是Linux系统进程类型的是 D

A 交互进程        B 批处理进程

C.守护进程  D.就绪进程

5.下列信息是某系统用ps -et命令列出的正在运行的进程,进程是运行Intenet超级服务器,它负贵监听intemet sockets上的连接,并调用合适的服务器来处理接收的信息。

A root 1 4.0 0.0 344 2047 S 17:09 0:00 init

B root 2 0.0 0.1 2916 15207 S 17:09 0:00 /sbin/getty

C root 3 0.0 0.2 1364 632? S 17:09 0:00 /usr/sbin/syslogd

D root 4 0.0 1344 12047 S 17:09 0:10 /usr/sbin/inetd

6. TCP/IP模型中,应用层包含了所有的高层协议,在下列的一些应用协议中,B 是能够实现本地与远程主机之间的文件传输工作。

A telnet     B FTP    C SNMP      D NFS

7.当我们与某远程网络连接不上时,就需要跟踪路由查看,以便了解在网络的什么位置出现了问题,满足该目的的命令是C.

A ping  B ifconflg    C traceroute           D netstat

8.组合多条SQL查询语句形成组合查询的操作符层(D

A.select       B.All     C.LINK     D.UNION

9.SQL,删除视图用(c)

A.DROP SCHEMA  B.CREATE TABLE  C.DROP VIEW     D.DROP INDEX

.数据库

在数据库中有如下三张表,

Student表:-学生基本信息表

Create table Student(

Sno Char (9) notnull.一学号

Sname Char (9) notnull,一姓名

Ssex-Char (2), 性别

Sage NUMBER (4). 一年龄

Sdept Char (20) 一所在系

SbirthdayDate 一出生年月日

Course表:课程信息表

Create table Course(

Cno Char(8) notnull,一课程号

Cname Char(10) notnull,一课程名

Cpno Char (8). 一选修课号

Ccredit NUMBER (4)notnull--学分

Scg表:选课信息表

createtableScg(

SnoChar(9) notnull,一学号

CnoChar(8) notnull,一课程号

SscoreNumber (6) 一成绩

1、查询名字叫李伟的90后的学生信息。

select * from student where to_char(sbirthday,‘yy‘)>‘89‘;

—— 将日期转化成字符,90 后大于 89    根据出生日期修改年龄

update student a  set a.gage=(select

to_number(to_char (sysdate,‘yyyy‘)-to_char (sbirthday,‘yyyy‘)) age from atudent b where a.sno=b.sno)

2、查询在信息系中数学课成绩高于王伟的学生姓名。

select stu.sname,stu.sdept,scg.sscore,c.cname from student stu join scg on  stu.sno=scg.sno and stu.sdept=‘信息

join courge c  on c.cno=acg.cno and c.cname=’数学’ and scg.sscore>(

select g.sscore from scg g where g.cno=(select cno from course wherecname=‘数学’)

and g.sno=(select sno from student where sname=‘王伟‘))

3.查询软件工程课成绩高于王伟,但是C语言低于王伟的学生姓名

select s.sno,s.sname,s1.cname,s1.sscore,s2.cname,s2.sscore from student s join(  select a.sno, b.cname, a.sscore

From scg a  Join course b on a.cno = b.cno  and b.cname=‘软件工程‘and  a.sscore  > (select g.sscore from scg g, course c

where g.cno = c.cno  and c.cname =‘软件工程

and g.sno= (select sno from student where sname =‘王伟‘)s1

on s.sno=sl.sno join (select a.sno, a.sscore,b.cname from scg a join course b on a.cno=b.cno and b.cname=‘c语言s2 on s1.sno=s2.sno

and s2.sscore <( select a.sscore from scg a join course b on a.cno=b.cno

and b.cname=‘c语言‘ and a.sno =(select sno from student where

gname=‘王伟‘))

4.查询刘伟的学分,学分取得规则是成绩高于 60 即可获得学分。------

select sum(c.ccredit) from course c join(

select s.sname,g.sscore ,g.cno ,g.sno from student s join scg g on s.sno=g.sno where sname=‘刘伟‘) b

on c.cno=b.cno and b.sscore>60

5.查询成绩为优秀的学生数量,显示所在系及优秀学生数量,优秀的条件是成绩高于90

Select stu.sdept, count (sno) from student stu where stu.sno in(  select scg.sno from scg where scg.sscore>90) group by stu.sdept

6.删掉JAVA 课的课程成绩

delete from scg sc where sc.cno=(select c.cno from course c where c.cnane=‘java‘)

set sc.sscore=sc.sscore-2 where sc.cno=(select c.cno from course c where c.cname =‘java‘)

7.向选课信息表里面增加刘伟同学的所有课程成绩,刘伟同学的成绩跟王伟是一样的

delete from scg where sno=

(select sno from student where sname=‘’)

insert into scg  (sno,cno, sscore)

select(select s.sno from student s where s.sname=‘刘伟‘) ,g.cno ,g.sscore from scg g where g.sno=(select sno from student where sname=‘王伟‘)

-8. 对于数学课成绩低于60分的女同学成绩统一增加5%.

update scg s set s.sscore=s.sscore*1.05 where s.cno=(select cno from course whecname=‘数学‘)

and sno in (select sno from student where ssex=1) and s.ssore>60

9. 用语句建立Student 表的各份表Student_bak

create table student_bak as select * from student;

select ·from student_bak;

Oc_date Result5-

.20090509   20090509   20090509     20090509

20090510   20090510   20090510  

如果要生成下列结果,该如何写sql语句?(sql server 或者 oracle语法皆口胜 负

20050509 2 2

20050510 1  2

select

    T.Oc_date

    ,sum(case when T.result=‘‘ then 1 else 0 end) 

    ,sum(case when T.result=‘‘ then 1 else 0 end) 

from

    Casewhen T

group by

T.Oc_date

或者:

select T.Oc_date,

count(case when T.result=‘‘ then 1 end) ,

count(case when T.result=‘‘ then 1 end) 

from Casewhen T group by T.Oc_date

SQL 数据库表名为 guest 、 数据库表名为 帐号 Accounts S0001 S0001 S0001 S0002 S0003 S0004 S0005 S0005 消费 Details 房费 酒水 房费 酒水 房费

房费 酒水 房费 时间 Date 2010-01-01 2010-01-02 2010-01-08 2010-01-29 2010-01-31 2010-02-01 2010-02-01 2010-02-02 金额 Money 280 120 300 50

180 230 100 128 班次 Class 001 001 003 002 001 001

1) 查询出房费都大于 200 的帐号。 ) 查询出房费 房费都大于 帐号。 Select accounts form guest where money >’200’

2) 查询出 1 月份每个帐号酒水和房费的总金额。 月份每个帐号酒水和房费的总金额。 每个帐号酒水和房费的总金额 ) Select sum(detail),details form guest where details=’房费’or details=’酒水’ group by detail

3) 删除 1 月份班次为空的记录。 月份班次为空的记录。 ) Delete form guest where date=>’2010-01-01’ and date=<’2010-01-31’and class is null

4) 将不是房费的记帐代码的班次都更改为‘001’ ) 将不是房费的记帐代码的班次都更改为‘ ’ Update guest set class=’001’were details >< ‘房费

5) 查询出消费都大于 100 的帐号。 的帐号。 ) 查询出消费都 Select distinct accounts form guest accounts not in (select distinct accounts form  guest money <’100’

已知表:Create Table Department

( dept_id varchar(2) not null, – 部门编号

dept_name varchar(20) not null, – 部门名称

dept_leader varchar(10) –部门经理

);

Create Table Personnel

( id varchar(4) not null, --员工号

name varchar(10) not null, --姓名

dept_id varchar(2) not null, --部门编号

age integer, --年龄

gzsj date, --参加工作时间

technical_post varchar(10), --职称

salary integer –薪水);

1.写出表Department增加一条记录 和 更新一条记录的 SQL语句

增加记录值 (‘12’, ‘研发部’, ‘张三’) ; 更新 dept_id=’12’的记录 (‘12’, ‘研发部’, ‘张三新’) ;

参考答案:

增加记录:Insert into Department(dept_id,dept_name,dept_leader) values (‘12’,’研发部’,’张三’)

更新记录:Update Department dept_leader=’张三新’ where dept_id=’12’;

需要给表Department增加一列字段notes,长度为10的字符串,默认值为‘0’ , 请写出相关SQL语句

参考答案:

Alter table Department add notes varchar(10) default 0;

3.查找工资大于2000元的员工记录,并按员工号id升序排列

参考答案:

Select name from Personnel where salary integer>2000 order by id;

4.查找工资大于2000元的员工所在部门、部门编号、部门经理、员工名称

参考答案:

Select dept_name,dept_id,dept_leader from Department where dept_id in(select dept_id from Personnel where salary integer>2000 );

5.查找张三和李四所在部门所有人员的姓名

参考答案:

Select name from Personnel where name=’张三’ and name=’李四’;

6、查看每个部门的部门经理和部门人数,按部门人数排序?

参考答案:

Select d.dept_leader,(select count(*) from Personnel p where d.dept_id=p.dept_id) from Department d,personnel p group by d.dept_id order by co;

7、删除表Department中的所有记录

参考答案:Delete from Department

8、删除表Department

参考答案:Drop table Department

 

实施面试题(1)

原文:https://www.cnblogs.com/z-12345/p/14594350.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!