版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 郵儲(chǔ)培訓(xùn)課件業(yè)務(wù)制度
- 車輛維修專業(yè)培訓(xùn)制度
- 病案培訓(xùn)考核制度
- 辦學(xué)培訓(xùn)規(guī)章制度
- 德邦企業(yè)培訓(xùn)制度
- 產(chǎn)科業(yè)務(wù)培訓(xùn)制度
- 兒科人員培訓(xùn)制度
- 生產(chǎn)計(jì)劃控制制度
- 中國(guó)鋼鐵生產(chǎn)制度
- 生產(chǎn)請(qǐng)示匯報(bào)工作制度
- 幼兒園老師面試高分技巧
- 航空運(yùn)輸延誤預(yù)警系統(tǒng)
- DLT 5142-2012 火力發(fā)電廠除灰設(shè)計(jì)技術(shù)規(guī)程
- 文化藝術(shù)中心管理運(yùn)營(yíng)方案
- 肩袖損傷臨床診療指南
- 2026年管線鋼市場(chǎng)調(diào)研報(bào)告
- 2025年江蘇省公務(wù)員面試模擬題及答案
- 2025中國(guó)家庭品牌消費(fèi)趨勢(shì)報(bào)告-OTC藥品篇-
- 機(jī)器人學(xué):機(jī)構(gòu)、運(yùn)動(dòng)學(xué)及動(dòng)力學(xué) 課件全套 第1-8章 緒論-機(jī)器人綜合設(shè)計(jì)
- JJG 694-2025原子吸收分光光度計(jì)檢定規(guī)程
- 廣東省2025屆湛江市高三下學(xué)期第一次模擬考試-政治試題(含答案)
評(píng)論
0/150
提交評(píng)論