ORACLE课件 第2章 编写简单的SELECT语句

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

1OracleSQL2SELECTOracle3SELECT:1)234•SQL••SQL••NULL•••DISTINCT•SQL*PLUS/iSQL*PLUS5•EMPLOYEES–employee_id)last_namejob_id()salary•JOBS–job_id()job_title•JOB_GRADES–grade_levellowest_salaryhighest_salary6•departments()–department_iddepartment_name()location_id•locations–location_id()street_adresscity7SQL•SQL(StructuredQueryLanguage)•SQLOracleDB2•SQL:–––––8SQL•DQLSelect•DMLInsert/Update/Delete/Merge•DDLCreate/Alter/Drop/Truncate•DCLGrant/Revoke•TCLCommit/Rollback/Savepoint9SELECT•–“*”–SELECT*|{[DISTINCT]|[][,...]}FROM;SELECT*|{[DISTINCT]|[][,...]}FROM;10•SELECT*FROMdepartments;SELECT*FROMdepartments;11•SELECTdepartment_id,department_name,manager_id,location_idFROMdepartments;SELECTdepartment_id,department_name,manager_id,location_idFROMdepartments;12SELECTdepartment_name,location_idFROMdepartments;SELECTdepartment_name,location_idFROMdepartments;13SQL•SQL–KeywordSQLSELECTFROM–statementSQLSELECT*FROMdepartments;–clauseSQLSELECT*FROMdepartments14SQL•SELECTselectSelect•,•SELECTSELSELECT•••15•+-*/•–––•NUMBER(+-*/)•DATE(+-)16SELECTemployee_id,last_name,salary,salary+400FROMemployees;SELECTemployee_id,last_name,salary,salary+400FROMemployees;SELECTemployee_id,last_name,salary,400+salary*12FROMemployees;SELECTemployee_id,last_name,salary,400+salary*12FROMemployees;SELECTemployee_id,last_name,salary,(400+salary)*12FROMemployees;SELECTemployee_id,last_name,salary,(400+salary)*12FROMemployees;17NULL•NULL•NULL––(||)SELECTlast_name,salary,(400+salary)*12+(400+salary)*12*commission_pctFROMemployees;SELECTlast_name,salary,(400+salary)*12+(400+salary)*12*commission_pctFROMemployees;18•––AS•–––19SELECTemployee_idid,last_nameasemployee_name,salarySalary,(400+salary)*12AnnualSalaryFROMemployees;SELECTemployee_idid,last_nameasemployee_name,salarySalary,(400+salary)*12AnnualSalaryFROMemployees;20•||SELECTfirst_name||''||last_name||'''sphonenumberis'||phone_numberemployeePhonenumberFROMemployees;SELECTfirst_name||''||last_name||'''sphonenumberis'||phone_numberemployeePhonenumberFROMemployees;21DISTINCT•DISTINCTSELECTDISTINCTdepartment_idFROMemployees;SELECTDISTINCTdepartment_idFROMemployees;SELECTDISTINCTdepartment_id,job_idFROMemployees;SELECTDISTINCTdepartment_id,job_idFROMemployees;22SQLSQL*PLUS/iSQL*PLUS•SQLSQL*PLUS/iSQL*PLUS–SQLSQL*PLUS/iSQL*PLUSOracle–SQLOracleSQL*PLUS/iSQL*PLUS–SQL*PLUS/iSQL*PLUS–SQLSQL*PLUS/iSQL*PLUS–SQL*PLUS/iSQL*PLUS;23SQL*PLUS/iSQL*PLUS•DESC[RIBE]–DESCemployees•SET–SET–SETHEADING{ON|OFF}ON•:–colHIREDATEformata100;–colDEPTNOformat999;324SQL*PLUS/iSQL*PLUSSETHEADINGOFFcolEMAILformata20selectEMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAILfromemployees;SETHEADINGONSETHEADINGOFFcolEMAILformata20selectEMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAILfromemployees;SETHEADINGON25•Sql*plus–Datecharacter–Numeric–•iSql*plus––26•SQL••••SQL••NULL•••DISTINCT•SQL*PLUS/iSQL*PLUS27•1.•2.10012•3.first_namelast_name“last_namefirst_name”•4.28

1 / 28
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功