教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 行业资料 >

习题课3-SQL语句练习

来源:网络收集 时间:2026-06-05
导读: 数据库系统概论An Introduction to Database System 北京建筑工程学院计算机系Beijing Architecture and Civil Engineering Institute Department of Computer Science Fall 2004 本章练习数据库样例数据库模式包括四个关系,它们的模式是Puduct(maker,model

数据库系统概论An Introduction to Database System

北京建筑工程学院计算机系Beijing Architecture and Civil Engineering Institute Department of Computer Science Fall 2004

本章练习数据库样例数据库模式包括四个关系,它们的模式是Puduct(maker,model,type) PC(model,speed,ram,hd,cd,price) Laptop(model,speed,ram,hd,screen,price) Printer(model,color,type,price)

假设型号为主健,事实上这个假设并不现实。

2011-12-26

An Introduction to Database System

PC

2011-12-26

Product

An Introduction to Database System

3

Laptop

Printer

2011-12-26

An Introduction to Database System

查询无数据源的查询 单表查询 复杂查询 增删改操作 SQL3递归查询

2011-12-26

An Introduction to Database System

SQL语句的无数据源检索所谓无数源检索就是使用SELECT语句来检索不在 表中的数据。例如,可以使用SELECT语句检索常 量、全局变量或已经赋值的变量。 无数据源检索实质上就是在客户机屏幕上显示出变 量或常量的值。

2011-12-26

An Introduction to Database System

使用SQL语句查看常量1.

查看常量select ‘sql server 2000’ select “Hello!Good morning!“

2011-12-26

An Introduction to Database System

使用SQL语句查看全局变量。2.

查询本地SQL Server服务器的版本信息。select @@version

2011-12-26

An Introduction to Database System

使用SQL语句查看全局变量。3.

查询本地SQL Server服务器使用的语言。select @@language

2011-12-26

An Introduction to Database System

使用TOP关键字SQL Server 2000提供了TOP关键字,让用户指定返回前面 一定数量的数据。当查询到的数据量非常庞大时(例如有 100万行),但没有必要对所有数据进行浏览时,使用TOP 关键字查询可以大大减少查询花费的时间。 语法格式如下:SELECT [TOP n | TOP n PERCENT] 列名1[,列名2,…列名n] FROM 表名

其中:TOP n表示返回最前面的n行,n表示返回的行数。 TOP n PERCENT表示返回的前面的n%行。2011-12-26 An Introduction to Database System 10

TOP关键字示例4.

从Product表中返回前面11行数据。select top 11* from customers

2011-12-26

An Introduction to Database System

TOP关键字示例5.

从Product表中返回前10%的数据。select top 10 percent * from Product

2011-12-26

An Introduction to Database System

查询无数据源的查询 单表查询 复杂查询 增删改操作 SQL3递归查询

2011-12-26

An Introduction to Database System

单表查询6.

从Product表中查询所有产品的信息。关系代数:σProduct.make,Product.model,Product.type(Product)

SQL语句:Select * from ProductSelect Product.make,Product.model,Product.type(Product)

2011-12-26

An Introduction to Database System

2011-12-26

An Introduction to Database System

选择7.

从Product表中查询A厂商生

产的所有产品的信息。关系代数: σProduct.maker=“A”(Product) 或者σmaker=“A”(Product) SQL语句 Select * from Product where Product.maker=‘A’

或者σ1=“A”(Product)

2011-12-26

An Introduction to Database System

…… 此处隐藏:217字,全部文档内容请下载后查看。喜欢就下载吧 ……
习题课3-SQL语句练习.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/2275569.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)