好文档 - 专业文书写作范文服务资料分享网站

数据库实验三 - 图文

天下 分享 时间: 加入收藏 我要投稿 点赞

实验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

数据库实验三 - 图文

实验3:数据库的简单查询和连接查询一、实验目的熟练掌握和使用SQLServer查询分析器的使用方法,加深对SQL和Transact-SQL语言的查询语句的理解。熟练掌握简单表的数据查询和数据排序的操作方法。二、实验内容1.数据表的导入和导出操作通过导入和导出功能实现数据表的转移和导入。2
推荐度:
点击下载文档文档为doc格式
2yazm79u6a05ej21u7w9
领取福利

微信扫码领取福利

微信扫码分享