OracleSQL基础知识论述10981.pptx





《OracleSQL基础知识论述10981.pptx》由会员分享,可在线阅读,更多相关《OracleSQL基础知识论述10981.pptx(57页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、1.Oracle SQL 基础基础Welcome!Rainny Zhong138265865711.1.Oracle SQL简介简介Dr.E.F.CoddDr.E.F.Codd published the paper,A Relational Model of Data for Large Shared Data Banks,in June 1970 in the Association of Computer Machinery(ACM)journal,Communications of the ACM.Codds model is now accepted as the definitiv
2、e model for relational database management systems(RDBMS).The language,Structured English Structured English Query LanguageQuery Language(SEQUEL)was developed by IBMIBM Corporation,Inc.,to use Codds model.SEQUEL later became SQL(still pronounced sequel).In 1979,Relational Relational Software,IncSoft
3、ware,Inc.(now Oracle Corporation)introduced the first commercially available implementation of SQL.Today,SQL is accepted as the standard RDBMS language.SQL StandardsSQL StandardsOracle Corporation strives to comply with industry-accepted standards and participates actively in SQL standards committee
4、s.Industry-accepted committees are the American National Standards Institute(ANSI)and the International Standards Organization(ISO),which is affiliated with the International Electrotechnical Commission(IEC).Both ANSI and the ISO/IEC have accepted SQL as the standard language for relational database
5、s.When a new SQL standard is simultaneously published by these organizations,the names of the standards conform to conventions used by the organization,but the standards are technically identical.The latest SQL standard was adopted in July 1999 and is often called SQL:99.The formal names of this sta
6、ndard are:ANSI X3.135-1999,Database Language SQL,Parts 1(Framework),2(Foundation),and 5(Bindings)ISO/IEC 9075:1999,Database Language SQL,Parts 1(Framework),2(Foundation),and 5(Bindings)1.1.1.Oracle SQL的处理过程的处理过程1.1.1.Oracle SQL的处理过程的处理过程处理SQL SQL 语句处理查询:语法分析:搜索同一语句 检查语法、对象名和权限 锁定语法分析过程中使用的对象 创建和存储执行
7、计划 绑定:获取变量值 执行:处理语句 提取:将结果行返回用户进程处理DML DML 语句:语法分析:与处理查询时的语法分析阶段相同。绑定:与处理查询时的绑定阶段相同。执行:如果数据库缓冲区高速缓存中不存在某些数据块和还原块,服务器进程就从数据文件将它们读入数据库缓冲区高速缓存。服务器进程锁定要进行修改的行。还原块用于存储数据的前像,以便在需要时回退DML 语句。数据块记录数据的新值。服务器进程将数据的前像记录到回退块中,并更新数据块。这两种更改都是在数据库缓冲区高速缓存中进行的。数据库缓冲区高速缓存中所有已更改的块都标记为灰数据缓冲区,即与磁盘中相应的块不同的缓冲区。DELETE或INSER
8、T命令的处理使用类似的步骤。DELETE命令的前像包含已删除行中的列值,而INSERT命令的前像中包含行的位置信息。处理DDL DDL 语句:DDL(数据定义语言)语句的执行与DML(数据操纵语言)语句和查询的执行不尽相同,因为成功执行DDL 语句需要对数据字典具有写权限。对于这些语句,语法分析阶段实际上包括分析、数据字典查找和执行。事务处理管理SQL 语句、会话管理SQL 语句和系统管理SQL 语句在语法分析和执行阶段处理。要重新执行这些语句,再次进入执行阶段即可。1.2.Oracle SQL基本元素基本元素DatatypesLiteralsFormat Models NullsPseudo
9、columns 1.2.1.Oracle SQL数据类型数据类型Oracle Built-in DatatypesANSI,DB2,and SQL/DS DatatypesUser-Defined Types Oracle-Supplied Types1.2.1.2.Oracle内置数据类型内置数据类型1.2.1.2.Oracle内置的数据类型概览内置的数据类型概览Character Datatypes-CHAR Datatype-NCHAR Datatype-NVARCHAR2 Datatype-VARCHAR2 Datatype NUMBER DatatypeLONG DatatypeDa
10、tetime and Interval Datatypes-DATE-TIMESTAMP-TIMESTAMP WITH TIME ZONE-TIMESTAMP WITH LOCAL TIME ZONERAW and LONG RAW DatatypesLOB-BLOB-CLOB-NCLOBROWID DatatypeBFILE Datatype1.2.2.Oracle SQL伪列伪列CURRVAL and NEXTVAL-sequence.CURRVAL-sequence.CURRVAL-sequence.NEXTVAL-sequence.NEXTVAL LEVELSELECT employe
11、e_id,last_name FROM employees WHERE(employee_id,LEVEL)IN SELECT employee_id,last_name FROM employees WHERE(employee_id,LEVEL)IN(SELECT employee_id,2 FROM employees)START WITH employee_id=2 CONNECT(SELECT employee_id,2 FROM employees)START WITH employee_id=2 CONNECT BY PRIOR employee_id=manager_id;BY
12、 PRIOR employee_id=manager_id;ROWIDSELECT ROWID,last_name FROM employees WHERE department_id=20;SELECT ROWID,last_name FROM employees WHERE department_id=20;ROWNUMSELECT*FROM employees WHERE ROWNUM 10;SELECT*FROM employees WHERE ROWNUM?/rdbms/admin/utlexcpt1Statement processed.2.SQL DESCRIBE excepti
13、ons注:注:utlexcpt1.sql脚本的确切名称和位置视操作系统而定。有关详细信息,请参阅脚本的确切名称和位置视操作系统而定。有关详细信息,请参阅专用于该操作系统的专用于该操作系统的Oracle文档。文档。1.3.12.获取约束信息获取约束信息1.4.Oracle SQL操作符操作符About SQL OperatorsAbout SQL OperatorsArithmetic OperatorsArithmetic OperatorsConcatenation OperatorConcatenation OperatorSet OperatorsSet OperatorsUser-De
14、fined OperatorsUser-Defined Operators1.4.1.集合操作符集合操作符UnionUnionUnion allUnion allIntersectIntersectMinusMinus1.4.1.集合操作符集合操作符-OE/OEOE/OE-UNION-UNIONselect location_id,select location_id,department_name Department,department_name Department,to_char(null)Warehouse to_char(null)Warehousefrom department
15、sfrom departmentsunionunionselect location_id,select location_id,to_char(null)Department,to_char(null)Department,warehouse_name warehouse_namefrom warehouses;from warehouses;-UNION ALL-UNION ALLSELECT location_id FROM locations SELECT location_id FROM locations UNION ALL UNION ALL SELECT location_id
16、 FROM departments;SELECT location_id FROM departments;-INTERSECT-INTERSECTSELECT product_id FROM inventoriesSELECT product_id FROM inventoriesINTERSECTINTERSECTSELECT product_id FROM order_items;SELECT product_id FROM order_items;-MINUS-MINUSSELECT product_id FROM inventoriesSELECT product_id FROM i
17、nventoriesMINUSMINUSSELECT product_id FROM order_items;SELECT product_id FROM order_items;1.4.1.集合操作符集合操作符-OE/OEOE/OE-UNION-UNIONselect location_id,select location_id,department_name Department,department_name Department,to_char(null)Warehouse to_char(null)Warehousefrom departmentsfrom departmentsun
18、ionunionselect location_id,select location_id,to_char(null)Department,to_char(null)Department,warehouse_name warehouse_namefrom warehouses;from warehouses;-UNION ALL-UNION ALLSELECT location_id FROM locations SELECT location_id FROM locations UNION ALL UNION ALL SELECT location_id FROM departments;S
19、ELECT location_id FROM departments;-INTERSECT-INTERSECTSELECT product_id FROM inventoriesSELECT product_id FROM inventoriesINTERSECTINTERSECTSELECT product_id FROM order_items;SELECT product_id FROM order_items;-MINUS-MINUSSELECT product_id FROM inventoriesSELECT product_id FROM inventoriesMINUSMINU
20、SSELECT product_id FROM order_items;SELECT product_id FROM order_items;1.5.表达式表达式About SQL ExpressionsAbout SQL ExpressionsSimple ExpressionsSimple ExpressionsCompound Expressions Compound Expressions CASE Expressions CASE Expressions CURSOR Expressions CURSOR Expressions Datetime ExpressionsDatetim
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- OracleSQL 基础知识 论述 10981

限制150内