关系数据库基础与应用

上传人:cn****1 文档编号:431495947 上传时间:2023-04-19 格式:DOCX 页数:2 大小:8.28KB
返回 下载 相关 举报
关系数据库基础与应用_第1页
第1页 / 共2页
关系数据库基础与应用_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

《关系数据库基础与应用》由会员分享,可在线阅读,更多相关《关系数据库基础与应用(2页珍藏版)》请在金锄头文库上搜索。

1、关系数据库基础与应用练习 21存储过程 1第一题:创建一个存储过程,名称为proctsinfo,该存储过程的功能是根据输入的出版社名称查询该出版社所出版的图书信息。create proc proctsinfo3publiname char(20)asselecttb_bookinfo.bookID,bookname,price,authorID,tb_bookinfo.publishIDfromtb_pubinfo,tb_bookinfowhere pubname=publiname and tb_pubinfo.publishID=tb_bookinfo.publishIDexec proc

2、tsinfo3 清华大学出版社第二题:创建一个存储过程,功能是向作者信息表中插入数据,并调用该存储过程插入一条 记录。执行create proc auto_insert(authorID char(4),authname char(20),sex char(2),age tinyint,authaddress char(30)asinsert into tb_authorinfo(authorID,authname,sex,age,authaddress) values(authorID,authname,sex,age,authaddress)exec auto_insert 1119,to

3、m,男,20,北京exec tb_authorinfo_add 1119,tom,男,20,北京第三题:创建一个存储过程,功能是根据输入的出版社名称修改图书表中的图书价格 执行:create proc book_update(pubname char(20),price decimal(18,2)asupdate dbo.tb_bookinfoset dbo.tb_bookinfo.price=price where dbo.tb_pubinfo.publishID=dbo.tb_bookinfo.publishID and dbo.tb_pubinfo.pubname=pubnameexec

4、 book_update 北京大学出版社,2exec tb_bookinfo_update 北京大学出版社,2第四题:创建一个存储过程根据输入的作者姓名删除作者表中的该作者信息执行 create proc auto_del authname char(20) asdelete tb_authorinfo where authname=authnameexec auto_del tom:exec tb_authorinfo_del tom第五题:使用T-SQL命令创建一个名为projcnt的存储过程,该存储过程可以根据输入的 性别统计出该性别的作者人数。如使用语句调用该存储过程declare sum intexec proc_cnt 女,sum outputprint 该性别的作者人数为+convert(char(2),sum)返回的结果如下所示:该性别的作者人数齿d

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号