① Oracle plsql编程的三道题目
4、使用case语句更新工资,10部门提高100,20部门提高200,30部门提高300,40部门提高400。
setserveroutputon
declarev_dptemp.dpt%type;
begin
selectdptintov_dptfromempwherename='zhangsan'
case
whenv_dpt='10'then
updateempsetsal=sal+100wherename='zhangsan';
whenv_dpt='20'then
updateempsetsal=sal+200wherename='zhangsan';
whenv_dpt='30'then
updateempsetsal=sal+300wherename='zhangsan';
whenv_dpt='40'then
updateempsetsal=sal+400wherename='zhangsan';
else
dbms_output.put_line('无法更新!');
endcase;
end;
5、分别使用3种循环计算10的阶乘
简单(loop)循环
declareinumber(2):=1;snumber(10):=1;
begin
loops:=s*i;
i:=i+1;
dbms_output.put_line(s);
exitwheni>10;
endloop;
end;
for循环
declareinumber(2):=1;snumber(10):=1;
begin
loop
s:=s*i;
i:=i+1;
dbms_output.put_line(s);
exitwheni>10;
endloop;
end;
while循环
declareinumber(2):=1;snumber(10):=1;
begin
whilei<=10loop
s:=s*i;
i:=i+1;
dbms_output.put_line(s);
endloop;
end;
6、使用for循环输出一个实心三角形,底边长由用户输入。
核心代码:
begin
foriin1..5loop
dbms_output.put_line(rpad(i,8-i,'')||rpad('*',2*i-1,'*'));
endloop;
end;
② 3道题目SQL怎么做大家帮帮我
4)
insert into Employees(EmployeeID, Name, Birthday, Sex, Address, Zip, PhoneNumber, EmailAddress, DepartmentID) values ('210678', '林涛', '1973-5-1', '1', '中山北路3号', '210002', '4055663', NULL, '5')
5)
update Employees set Birthday='1967-4-2' where Name = '林涛'
6)--存储过程
create procere insertEmployees
@Employeeid varchar(20),@Name varchar(20),@Birthday datetime,@Sex char(1),
@Address varchar(300),@Zip varchar(6),@PhoneNumber varchar(20),
@EmailAddress varchar(50),@DepartmentID varchar(30)
as
begin
insert into Employees
(EmployeeID, Name, Birthday, Sex, Address, Zip, PhoneNumber,
EmailAddress, DepartmentID)
values(@EmployeeID, @Name,@Birthday, @Sex, @Address, @Zip, @PhoneNumber,
@EmailAddress, @DepartmentID)
end
--调用存储过程
exec insertEmployees '308759',' 叶凡', '1968-1-1','1', '北京西路3号',
'210001', '33089056', NULL, '4'
③ 求 3道SQL选择题,稍微有点难度的
1.隐藏系统数据库操作中使用到的菜单命令是( )。
A 、选中要隐藏的系统数据库后选择 [ 操作 ] 4 [ 属性 ] 菜单命令
B 、选中要隐藏的系统数据库后选择 [ 查看 ] 4 [ 自定义 ] 菜单命令
C 、选中 SQL Server 服务器后选择 [ 操作 ] 4 [ 编辑 SQL Server 注册属性 ] 菜单命令
D 、都可以
2.下面关于 SQL Server 登录账户叙述错误的是( )。
A 、 默认情况下, Windows 的系统管理员账户自动成为 SQLServer 登录账户
B 、在企业管理器中可修改 Windows 登录账户的登录密码
C 、在企业管理器中可修改 SQL Server 登录账户的登录密码
D 、SQL Server 安装在 Windows NT 或 2000 中才有 BUILTI NAdministrators 登录账户,否则只有 sa 账户
3.下列关于对象浏览器叙述错误的是( )。
A 、在编辑查询时,可将数据库、表或字段名称拖放到查询窗口中
B 、将数据库或字段名称拖放到查询窗口中可直接添加数据库或字段名称
C 、拖放表名,可在查询中添加该表的所有字段名称
D 、拖放模板,可添加模板中的 SQL 命令
4.下列关于关系数据库叙述错误的是( )。
A、 关系数据库的结构一般保持不变,但也可根据需要进行修改
B 、一个数据表组成一个关系数据库,多种不同的数据则需要创建多个数据库
C 、关系数据表中的所有记录的关键字字段的值互不相同
D 、 关系数据表中的外部关键字不能用于区别该表中的记录
5.下列关于数据库的数据文件叙述错误的是( )。
A 、创建数据库时必须指定数据文件
B 、创建数据库时, PRIMARY 文件组中的第一个文件为数数据文件
C 、一个数据库可以有多个数据文件
D 、一个数据库只能有一个主数据文件
6.在使用 Recordset 对象时,如果要查看其他用户的更改操作,则应将游标类型定义为( )。
A 、动态游标或键集游标
B 、键集游标或静态游标
C 、静态游标或仅向前游标
D 、仅向前游标或动态游标
④ sql语句 面试题
A.创建表格CODE省略
注明:学生表PK stu_id 课程表pk cos_id 分数表PK enrollment_id FK stu_id,cos_id
B.插入数据code省略
C.Query
select s.stu_id,stu_name,count(cos_id) from student s,enrollments e where s.stu_id = e.stu_id and e.grade>60 group by s.stu_id,stu_name;
select e.stu_id,s.stu_name,c.cos_name from student s,enrollments e,course c
where s.stu_id = e.stu_id
and e.cos_id = c.cos_id
and c.cos_name = 'CHINESE'
and s.stu_name like 'W%';
select stu_id,stu_name from (select e.stu_id,stu_name,cos_name from enrollments e,student s,course c
where s.stu_id = e.stu_id
and e.cos_id = c.cos_id
and c.cos_name IN ('CHINESE','MUSIC'))
group by stu_id,stu_name
having count(cos_name) = 2
select distinct e.cos_id,c.cos_name,count(e.stu_id) stu_count,count(e.stu_id)-NVL(A.FAIL,0) upscore,(count(e.stu_id)-NVL(A.FAIL,0))/count(e.stu_id) rate from
(select cos_id,count(stu_id) fail from enrollments where grade<60 group by cos_id) a,enrollments e,course c
where e.cos_id = a.cos_id(+)
and e.cos_id = c.cos_id
group by e.cos_id,NVL(a.fail,0),c.cos_name;
update student
set avg_grade =(select avg(grade) X from enrollments group by stu_id
having student.stu_id = enrollments.stu_id);
select stu_id,avg(grade) from
(select stu_id,cos_id,grade,row_number() over(partition by stu_id order by grade ) X from enrollments)
group by stu_id
having count(*)<=2
UNION
select A.stu_id,avg(A.grade)from
(select stu_id,cos_id,grade,row_number() over(partition by stu_id order by grade ) X from enrollments) A,
(select stu_id,count(*) c from
(select stu_id,cos_id,grade,row_number() over(partition by stu_id order by grade ) X from enrollments)
group by stu_id) B
where A.stu_id = B.stu_id
and A.x>1 and x<B.c
group by A.stu_id,b.c
_________________________________________________
环境:oracle 10g/TOAD 以上代码均通过测试,如有问题,请联系,谢谢
⑤ 哪位大虾帮忙解下三道SQL语句题,谢了,在线等,急急急!!!
第一题的 1 关系代数实现 应该是 πgrade((πsno='李明'(student)∞sc) ÷π(δcname='数据库原理'(course)))
那个自然连接我没找到对应的符号,用无穷大代替了
⑥ SQL语句问题 3道简单的题 最好再给我简单讲讲
第一个:查询计算机专业“计算机导论”课程的学生姓名、课程名、成绩,并按成绩降序排列
select a.姓名,b.课程名,c.成绩 from 学生信息表 a,课程信息表 b,成绩信息表 c
where a.学号=c.学号
and b.课程号=c.课程号
and a.专业名='计算机'
and b.课程名='计算机导论'
order by 成绩 desc
第二个:查询“计算机导论”课程成绩高于80分的学生学号、姓名、专业名;
select a.学号,a.姓名,a.专业名 from 学生信息表 a,课程信息表 b,成绩信息表 c
where a.学号=c.学号
and b.课程号=c.课程号
and b.课程名='计算机导论'
and c.成绩>80
第三个:查询“计算机导论”课程成绩高于80分的学生学号、姓名、课程名、成绩;
select a.学号,a.姓名,b.课程名,c.成绩 from 学生信息表 a,课程信息表 b,成绩信息表 c
where a.学号=c.学号
and b.课程号=c.课程号
and b.课程名='计算机导论'
and c.成绩>80
⑦ sql数据库这三道题应该怎么做
注意:小写的字母为表的别命名,字段大小写没有区分,你要是区分的话区分下,sql 查询器里面可以设置
查询订单金额最高的客户名、货品名称、购买数量、金额和下单时间。
select c.cname 客户名,p.pname 货品名称,o.quantity 购买数量,max(o.money)金额,o.orderdate下单时间
from Customer c,Proct p, Orders o
where c.cid=o.cid and o.oid=p.pid
2.查询库存量低于10的商品名称
select p.pname 货品名称
from Proct p
where p.quantity<10
3.
假设订单表Orders已创建,为该表添加默认值约束,订单日期为当前日期
Alter table Orders Alter Column 订单日期 datetime default getdate()
⑧ 高分求SQL数据库三道小题
1.select 客户ID,姓名
form 租赁,客户
where 客户. 客户ID=租赁.客户ID and 设备ID='笔记本'
2.select *
from 租赁
where 设备ID is null
3.select 设备类别,count(设备ID),sum(设备表.日租金*租赁表.租期)
from 设备,租赁
group by 设备类别
⑨ SQL高手请进高分请你做3道简单的题目
问题一:要求不清晰,借书和还书这个要求不明确
问题二:
select b.books_name,c.user_name
from lease a, books b, user c
where a.books_ID=b.books_ID and a.user_ID=c.user_ID
and loan_date between '2006-07-02' and '2007-07-05'
问题三:
select b.books_name,c.user_name
from lease a, books b, user c
where a.books_ID=b.books_ID and a.user_ID=c.user_ID
and YEAR(loan_date) = '2006'
⑩ 高分悬赏几道计算机SQL数据库的题!做出来了先支付100分,要是满意的话,在加赏50~
1. 查询雇员(employee)的姓和名
Select substring(username,1,1) as 姓 from employee
Select substring(username,2,2) as 名 from employee
2. 查询雇员的姓名
Select username from employee
3. 查询雇员数
Select count(*) from employee
4. 查询雇员的姓名和职务
Select username,,ty from employee
5. 查询雇员的工龄
Select year(getdate())-开始工作日期 as 工龄 from employee
任务2:条件查询
1. 查询雇员(employee)从事"Sales Representative"职务的有哪些人
Select * from employee where ty=’ Sales Representative’
2. 查询工龄超过15年的雇员
Select * from employee where cast( (year(getdate())-开始工作日期) as int)>=15
3. 查询姓以a开头的雇员
Select * from employee where username like ‘a%’
4. 查询姓的开头字母在m以后的雇员
Select * from employee where cast((substring(username,1,1) as varchar)>=’m’
5. 认为hire_date是雇员生日,查询巨蟹座的雇员
Select * from employee where birthday between ‘6-22 ‘ and ‘7-22’
任务3:联合查询
1. 查询雇员和雇员职位
Select a.id,b.ty from employee, as a,jobs as b
2. 查询雇员、雇员职位和雇员所在出版社
Select a.id,b.ty, b.publishing from employee as a,jobs as b on a.id=b.id
3. 查询雇员、雇员工资、雇员离本职位最高工资的差值
select a. ID,a.username,a.[雇员工资],b.[最高工资]-a.[雇员工资] as [差值] from employee a,jobs b where a.[职位]=b.[职位]