页数:22页文件大小:105.0 KB来源: 计算机专业英语ppt课件
本课件对应4.4 Structured Query Language(结构化查询语言)一节,讲解 SQL 的数据定义、查询与更新语句,说明 SELECT 子句与条件表达式的书写方式。课文配中英文对照译文、生词短语表与课后练习,可用于课堂讲授与课前预习。
| 单词 | 词性 | 中文释义 |
|---|---|---|
| asterisk | n. | 星号 |
| clause | n. | 子句,条款 |
| commercial | adj. | 商业的,贸易的 |
| comprehensive | adj. | 全面的,广泛的,能充分理解的,包容的 |
| denote | v. | 指示,表示 |
| eliminate | v. | 排除,消除,除去 |
| genre | n. | 类型,流派4.4 Structured Query LanguageWords |
| 单词 | 词性 | 中文释义 |
|---|---|---|
| pattern | n. | 模范,式样,模式,样品,格调,图案v.仿造,以图案装饰,形成图案 |
| primary | adj. | 第一位的,主要的,初步的,初级的,原来的 |
| proficient | n. | 精通 |
| rating | n. | 等级级别(尤指军阶),额定 |
| rent | v. | 租,租借,出租n.租金 |
| restriction | n. | 限制,约束 |
| retrieve | v. | 重新得到 |
| selective | adj. | 选择的,选择性的 |
| 单词 | 词性 | 中文释义 |
|---|---|---|
| separator | n. | 分隔符,隔离物,分离者 |
| specify | v. | 指定,详细说明,列入清单 |
| thriller | n. | 惊险读物,电影,戏剧 |
| 缩写 | 英文全称 | 中文含义 |
|---|---|---|
| ANSI | American National Standards Institute | 美国国家标准化组织 |
考虑图4.2所示的数据库表,该表包含有关影片的信息。表中的每一行对应一个记录,表中的每个记录由相同的存储特定值的字段组成。也就是说,每个影片记录有影片标识、名称、流派、分级,这些字段包含每个记录的特定数据。每个数据库表应该有一个名字,这样将该表命名为Movie。
Consider the database table shown in Figure 4.2, which contains information about movies. Eachrowinthe table corresponds to a record. Eachrecordin the table is made up of the same fields in which particular values a restored. Thatis, each movie record has a Movie Id, a Title, a Genreanda Rating that contain the specific data for each record. A database table is given a name, such as Movieinthis case. 4.4 Structured Query Language
假设我们想建立一个影片租赁业务。除了要出租的影片列表之外,我们还必须建立一个数据库表保存我们的客户信息。图4.3中的Customer表可以表示这方面的资料。
我们可以使用SQL对这些表格进行选择性数据检索、更新和改变数据、删除数据等。
Supposewe wanted to create a movie rental business. In addition to the list of movies for rent, we must create a database table to hold information about our customers. The Customer table in Figure 4.3 could represent this information.
Wecanuse SQLto retrieve selective data, update and change data, deleted ataetc. from these tables.
语言点分析:复合句。句中非限制性定语从句asitsnameimplies作插入语,as指代整个主句内容。
结构化查询语言(SQL)是一个用于管理关系数据库的全面的数据库语言。它包括描述数据库方案的语句以及添加、修改和删除数据库内容的语句。顾名思义,它还包括能够查询数据库来检索特定数据的功能。
The Structured Query Language (SQL)is a comprehensive database language for managing relational databases. It includes statements that specify database schemas as well as statements that add, modify, and delete database content.[1]It also includes, as its name implies, the ability to query the database to retrieve specific data.
SQL的最初版本是Sequal,20世纪70年代初由IBM开发。1986年,美国国家标准学会(ANSI)公布SQL标准,SQL标准是访问关系数据库的商业数据库语言的基础。
SQL是不区分大小写的,因此,关键字、表名和属性名称可以大写、小写或大小写混合。空格被用作为语句中的分隔符。
The original version of SQLwas Sequal, developed by IBMinthe early 1970 s. In 1986, the American National Standards Institute (ANSI)published the SQLstandard, the basis for commercial database languages for accessing relational databases.
SQLisnotcase sensitive, so keywords, table names, and attribute names can be uppercase, lowercase, or mixed. Spacesare used as separators in a statement.
查询
让我们首先关注简单查询。select语句是实现这一目的的主要手段。基本的select语句包含一个select子句、一个from子句和一个where子句:
Queries
Let’s first focus on simple queries. The select statement is the primary tool for this purpose. The basic select statement includes a select clause, a from clause, and a where clause:
select属性列表from表名列表where条件
select子句确定返回的属性,from子句确定查询用到哪些表,where子句限制返回的数据。例如:
select attribute-list from table-list where condition
The select clause determines what attributes are returned. The from clause determines what tables are used in the query. The where clause restricts the data that is returned. Forexample:
select Title from Movie where Rating=‘PG’
这个查询的结果是Movie数据表中的分级是PG的所有名称的列表。如果没有必需的特殊限制,where子句可以省略:
select Title from Movie where Rating=‘PG’
The result of this query is a list of all titles from the Movietable that have a rating of PG. The where clause can be eliminated if no special restrictions are necessary:
select Name, Address from Customer
此查询返回客户表中所有客户的名称和地址。星号(*)可用于select子句中表示需要返回选中记录的所有属性:
select Name, Address from Customer
Thisquery returns the name and address of all customers in the Customer table. Anasterisk (*)can be used in the select clause to denote that all attributes in the selected records should be returned:
select*from Movie where Genrelike‘%action%’
此查询将返回Movie表中的Genre属性包含单词action的记录的所有属性。SQL的like操作符对字符串执行一些简单的模式匹配,%符号匹配任何字符串。
select*from Movie where Genrelike‘%action%’
Thisquery returns all attributes of records from the Movietablein which the Genre attribute contains the word‘action’. The like operator in SQLperforms some simple pattern matching on strings, andthe%symbol matches any string.
使用orderby子句,select语句也可以决定查询的结果应该如何排序:
select*from Movie where Rating=’R’order by Title
此查询将返回按影片名排序的R级电影的所有属性。
Select statements can also dictate how the results of the query should be sorted using the order by clause:
select*from Movie where Rating=‘R’order by Title
Thisquery returns all attributes of R-rated movies sorted by the movie title.
相对于已经列出来的,SQL支持的select语句还有更多的变化形式。请记住,我们的目标是给你介绍数据库的概念。为了真正精通SQL查询,您将需要更多的细节。
There are many more variations on select statements supported by SQLthanthose we’veshown here. Remember that our goal is to introduce the database concepts to you. You would require much more detail to truly become proficient at SQLqueries.
修改数据库内容
SQL的insert、update和delete语句允许改变数据表中的数据。insert语句向表中增加一个新的记录。每个insert语句指定新纪录的属性的值。例如:
Modifying Database Content
The insert, update, and delete statements in SQLallowthe data in a table to be changed. The insert statement adds a new record to a table. Eachinsert statement specifies the values of the attributes for the new record. Forexample:
insert into Customer values (9876,‘John Smith’,‘602 Greenbriar Court’,‘2938321234020299’)
该语句插入一个具有指定属性的新记录到Customer表。
insert into Customer values (9876,‘John Smith’,‘602 Greenbriar Court’,‘2938321234020299’)
This statement inserts a new record into the Customer table with the specified attributes.
update语句改变表的一个或多个记录的值。例如:
update Movieset Genre=‘thriller drama’where title=‘Unbreakable’
该语句将Movie表中的Title(名称)为'Unbreakable'(《坚不可摧》)的Genre(流派)属性改为‘thrillerdrama’(惊险剧)
The update statement changes the values in one or more records of a table. Forexample:
update Movieset Genre=‘thriller drama’where title=‘Unbreakable’
This statement changes the Genreofthe movie Unbreakable to‘thriller drama’.
The delete statement removes all records from a table matching the specified condition. Forexample, if we wanted to remove all R-rated movies from the Movietable, we could use the following delete statement:
delete from Movie where Rating=‘R’
[2]As with the select statement,there are many variations of the insert,update,and delete statements as well.分析:简单句。句中aswith:与……一样,例如:Oneday,as with all tyrannies,Myanmar's will fall.终有一天,就像所有的专制政权一样,缅甸军人政权会崩溃。
Delete语句删除数据库中所有符合特定条件的记录。例如,如果想从Movie表中删除所有R级影片,可以使用下面delete语句:
delete from Movie where Rating=‘R’
与select语句一样,insert、update和delete语句也有许多不同形式。
Exercises
Ⅰ. Write true or false for the following statements according to the passage.
1. ( ) The Structured Query Language (SQL) is a comprehensive database language for managing relational databases.
2. ( )The SQL includes statements that add, modify, and delete database content.
3. ( ) The original version of SQL was Sequal, developed by IBM in 1986.
4. ( ) SQL is case sensitive, so keywords, table names, and attribute names must be lowercase.
5. ( ) The basic select statement includes a select clause, a from clause, and a where clause.
6. ( ) The where clause determines what tables are used in the query.
7. ( ) The from clause can be eliminated if no special restrictions are necessary.
8. ( ) The like operator in SQL performs some simple pattern matching on strings.
习题4.4 二 填空:根据课文内容在横线处填入恰当的词。
Fill in the blanks according to the passage..
习题4.4 三 翻译:将下列单词和短语译成中文。
Translate the following words and expressions into Chinese..
下载地址:{{downurl}}
{{{a}}}
{{#b}}{{{b}}}
{{/b}} {{/title}} {{#nolog}}登陆注册
{{/nolog}} {{#djsx}}点我刷新
{{/djsx}} {{#gocz}} {{/gocz}} {{#ffqr}} {{/ffqr}}