




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Retrieving Data Using the SQL SELECT StatementObjectivesAfter completing this lesson, you should be able to do the following:List the capabilities of SQL SELECT statementsExecute a basic SELECT statementLesson AgendaBasic SELECT statementArithmetic expressions and NULL values in the SELECT statement
2、Column aliasesUse of concatenation operator, literal character strings, alternative quote operator, and the DISTINCT keywordDESCRIBE commandCapabilities of SQL SELECT StatementsSelectionProjectionTable 1Table 2Table 1Table 1JoinBasic SELECT StatementSELECT identifies the columns to be displayed.FROM
3、 identifies the table containing those columns.SELECT *|DISTINCT column|expression alias,.FROM table;Selecting All ColumnsSELECT *FROM departments;Selecting Specific ColumnsSELECT department_id, location_idFROM departments;Writing SQL StatementsSQL statements are not case sensitive.SQL statements ca
4、n be entered on one or more lines.Keywords cannot be abbreviated or split across lines.Clauses are usually placed on separate lines.Indents are used to enhance readability.In SQL Developer, SQL statements can be optionally terminated by a semicolon (;). Semicolons are required when you execute multi
5、ple SQL statements.In SQL*Plus, you are required to end each SQL statement with a semicolon (;).Column Heading DefaultsSQL Developer:Default heading alignment: Left-alignedDefault heading display: UppercaseSQL*Plus:Character and Date column headings are left-aligned.Number column headings are right-
6、aligned.Default heading display: UppercaseLesson AgendaBasic SELECT statementArithmetic expressions and NULL values in the SELECT statementColumn AliasesUse of concatenation operator, literal character strings, alternative quote operator, and the DISTINCT keywordDESCRIBE commandArithmetic Expression
7、sCreate expressions with number and date data by using arithmetic operators.Multiply*Divide/Subtract-Add+DescriptionOperatorSELECT last_name, salary, salary + 300FROM employees;Using Arithmetic OperatorsSELECT last_name, salary, 12*salary+100FROM employees;Operator PrecedenceSELECT last_name, salary
8、, 12*(salary+100)FROM employees;12注:题17 Defining a Null ValueNull is a value that is unavailable, unassigned, unknown, or inapplicable.Null is not the same as zero or a blank space.SELECT last_name, job_id, salary, commission_pctFROM employees; SELECT last_name, 12*salary*commission_pctFROM employee
9、s;Null Values in Arithmetic ExpressionsArithmetic expressions containing a null value evaluate to null.Lesson AgendaBasic SELECT statementArithmetic expressions and NULL values in the SELECT statementColumn aliasesUse of concatenation operator, literal character strings, alternative quote operator,
10、and the DISTINCT keywordDESCRIBE commandDefining a Column AliasA column alias:Renames a column headingIs useful with calculationsImmediately follows the column name (There can also be the optional AS keyword between the column name and the alias.)Requires double quotation marks if it contains spaces
11、 or special characters, or if it is case-sensitive Using Column AliasesSELECT last_name Name , salary*12 Annual SalaryFROM employees;SELECT last_name AS name, commission_pct commFROM employees;注:题12、题15Lesson AgendaBasic SELECT StatementArithmetic Expressions and NULL values in SELECT statementColum
12、n AliasesUse of concatenation operator, literal character strings, alternative quote operator, and the DISTINCT keywordDESCRIBE commandConcatenation OperatorA concatenation operator:Links columns or character strings to other columnsIs represented by two vertical bars (|)Creates a resultant column t
13、hat is a character expressionSELECTlast_name|job_id AS EmployeesFROM employees;Literal Character StringsA literal is a character, a number, or a date that is included in the SELECT statement.Date and character literal values must be enclosed within single quotation marks.Each character string is out
14、put once for each row returned.Using Literal Character StringsSELECT last_name | is a |job_id AS Employee DetailsFROM employees;Alternative Quote (q) OperatorSpecify your own quotation mark delimiter.Select any delimiter.Increase readability and usability.SELECT department_name | q Departments Manag
15、er Id: | manager_id AS Department and Manager FROM departments;注:题13Duplicate RowsThe default display of queries is all rows, including duplicate rows.SELECT department_idFROM employees;SELECT DISTINCT department_idFROM employees;12注:题14Lesson AgendaBasic SELECT statementArithmetic expressions and N
16、ULL values in the SELECT statementColumn aliasesUse of concatenation operator, literal character strings, alternative quote operator, and the DISTINCT keywordDESCRIBE commandDisplaying the Table StructureUse the DESCRIBE command to display the structure of a table.Or, select the table in the Connect
17、ions tree and use the Columns tab to view the table structure.DESCRIBE tablenameUsing the DESCRIBE CommandDESCRIBE employees QuizIdentify the SELECT statements that execute successfully.SELECT first_name, last_name, job_id, salary*12 AS Yearly SalFROM employees; SELECT first_name, last_name, job_id,
18、 salary*12 yearly salFROM employees; SELECT first_name, last_name, job_id, salary AS yearly salFROM employees;SELECT first_name+last_name AS name, job_Id, salary*12 yearly salFROM employees;SummaryIn this lesson, you should have learned how to:Write a SELECT statement that:Returns all rows and columns from a tableReturns specified columns from a tableUses column aliases to disp
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年子宫收缩药合作协议书
- 2025年特种铜合金材料合作协议书
- 2025年外卖骑手项目合作计划书
- 2025年专门用途灯具:工艺装饰灯具项目建议书
- 智慧城市公共服务信息安全的保障策略
- 汽车工程师的技能进阶与行业趋势
- 商业培训中的适应性教育与个性化学习实践
- 智慧城市基础设施的能源管理技术发展趋势
- 智能科技如何为地方教育事业注入新活力
- 中职数学椭圆课件
- 4.6.3神经系统支配下的运动 课件 人教版八年级生物上册
- 《民营经济促进法》金融支持条款的解读与实施路径研究
- 2023-2024学年山东省日照市高二下学期期末考试数学试题(解析版)
- 2024年 北京市公务员考试(行测)考试真题试题(附答案)
- 既有建筑地基基础加固技术规范 JGJ 123-2012知识培训
- 2025至2030中国改装车行业深度发展研究与企业投资战略规划报告
- 中医执业医师历年真题及解答
- MT/T 1222-2024液压支架再制造工程设计指南
- 2025年7月浙江省普通高中学业水平考试历史仿真模拟卷01(含答案)
- 2024-2025学年人教版PEP六年级下学期期末试卷(含答案含听力原文无音频)
- 2025-2030年中国聚脲涂料行业市场现状供需分析及投资评估规划分析研究报告
评论
0/150
提交评论