第一范文网 - 专业文章范例文档资料分享平台

数据库实验三 - 图文

来源:用户分享 时间:2025/10/13 4:10:20 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

实验3:数据库的简单查询和连接查询

一、 实验目的

熟练掌握和使用SQL Server查询分析器的使用方法,加深对SQL和Transact-SQL语言的查询语句的理解。熟练掌握简单表的数据查询和数据排序的操作方法。

二、 实验内容

1. 数据表的导入和导出操作

通过导入和导出功能实现数据表的转移和导入。 2. 简单查询操作。

该实验包括投影、选择条件表达、数据排序等。

三、 实验步骤

? 基本操作实验 I :通过导入和导出功能实现数据表的转移和导入。 步骤一:

建立数据库和表,并数据

步骤二:打开SQL Server管理平台,展开服务器和数据库,右击该数据库图标,从弹出的快捷菜单中选择“任务→导入数据”选项,启动数据导入向导工具,就会出现欢迎使用向导对话框,对话框中列出了导入向导能够完成的操作。

步骤三:单击“下一步”按钮,则出现选择数据源对话框,在该对话框中,可以选择数据源类型、文件名、用户名和密码等选项

步骤四:导出成功

? 基本操作实验 II:简单查询实验

1. To find all loan number for loans made at the Perryridge branch with loan

amounts greater than $1200.

select loan_number

from loan

where branch_name='Perryridge' and amount > 1200

2. Find the loan number of those loans with loan amounts between $900 and

$1,500

select loan number

from loan

where amount between 900 and 1500

3. Find the customer names and their loan numbers for all customers having a loan at

some branch.

select customer_name, T.loan_number, S.amount from borrower as T, loan as S where T.loan_number = S.loan_number

4. Find the number of tuples in the customer relation

select count (*)

from customer

5. Find the number of depositors in the bank

select count (distinct customer_name) from depositor

6. Find all customers who have both an account and a loan at the bank

select distinct customer_name from borrower

where customer_name in

(select customer_name from depositor )

7. Find the number of depositors for each branch. select loan_number

from loan

where amount is null

8. Find all loan number which appear in the loan relation with null values for amount

select loan_number from loan

where amount is null

搜索更多关于: 数据库实验三 - 图文 的文档
数据库实验三 - 图文.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c2yazm79u6a05ej21u7w9_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top