




下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Database InterfacesObjectivesAfter completing this lesson, you should be able to do the following:Use SQL*Plus and iSQL*Plus to access the Oracle Database 10gDescribe the logical structure of tablesUse SQL to query, manipulate, and define dataIdentify common database interfacesWhat Is SQL?SQL provid
2、es statements for a variety of tasks, including:Querying data Inserting, updating, and deleting rows in a table Creating, replacing, altering, and dropping objects Controlling access to the database and its objects SQL unifies all of the preceding tasks in one consistent language.Using SQLThere are
3、several tools for interfacing with the database using SQL:Oracle SQL*Plus and iSQL*Plus Oracle Forms, Reports, and DiscovererOracle Enterprise Manager Third-party toolsEnterprise Manager: Seeing the SQLWhat Is SQL*Plus?Command-line toolUsed interactively or in batch mode$ sqlplus /nologSQL*Plus: Rel
4、ease .0 - Production on Tue Feb 17 06:17:14 2004Copyright (c) 1982, 2004, Oracle. All rights reserved.SQL connect ricEnter password:Connected.SQL SELECT * FROM dual;D-XSQLWhat Is iSQL*Plus?What Is iSQL*Plus?Full Notes PageUsing iSQL*PlusDescribing DataQuerying DataThe SELECT has three basic
5、parts:The SELECT ListThe FROM clauseThe WHERE condition (optional)Sorting the DataSQL SELECT last_name, department_id, phone_number 2 FROM employees 3 ORDER BY last_name;LAST_NAME DEPARTMENT_ID PHONE_NUMBER Abel 80 011.44.1644.429267Ande 80 011.44.1346.629268Atkinson 50 650.124.6234Austin 60 590.423
6、.4569Baer 70 515.123.8888Baida 30 515.127.4563Banda 80 011.44.1346.729268Joining TablesGetting data from more than one tableJoining TablesFull Notes PageManipulating DataSQL INSERT INTO employees 2 (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER, 3 MISSION_PCT, 4 MANAGER_ID,DEPARTMENT_ID) 5 VAL
7、UES 6 (9999,Bob,Builder, ,NULL,sysdate, 7 IT_PROG,NULL,NULL,100,90);1 row created.SQL UPDATE employees SET SALARY=6000 2 WHERE EMPLOYEE_ID = 9999;1 row updated.SQL DELETE from employees 2 WHERE EMPLOYEE_ID = 9999;1 row deleted.Defining DataOverview of TransactionsTransaction 1Transaction 2COMMIT;Tra
8、nsaction Control StatementsSQL SELECT * FROM local_temp;no rows selectedSQL INSERT INTO local_temp VALUES 2 (SYSDATE, 76, 58);1 row created.SQL SELECT * from local_temp;TEMP_DATE HI_TEMP LO_TEMP 27-OCT-03 76 58SQL ROLLBACK;Rollback complete.SQL SELECT * FROM local_temp;no rows selectedLocking DataOr
9、acle Database 10g automatically locks data so that only one user can make changes at a time.Other Statement Categories Session control statements: Manage the properties of a user sessionSystem control statement: Manages the properties of an Oracle instanceEmbedded SQL statements: SQL statements with
10、in a procedural language programWhat Is PL/SQL?PL/SQL is a block-structured language, which extends SQL with:Declarations:VariablesConstantsCursorsControl structures:Conditional controlIterative controlSequential controlError handlingExample PL/SQL BlockDECLARE qty_on_hand NUMBER(5);BEGIN SELECT qua
11、ntity INTO qty_on_hand FROM inventory WHERE product = TENNIS RACKET FOR UPDATE OF quantity; IF qty_on_hand 0 THEN - check quantity UPDATE inventory SET quantity = quantity - 1 WHERE product = TENNIS RACKET; INSERT INTO purchase_record VALUES (Tennis racket purchased, SYSDATE); ELSE INSERT INTO purch
12、ase_record VALUES (Out of tennis rackets, SYSDATE); END IF; COMMIT;END;Uses of PL/SQLBlocks of PL/SQL are used in:Anonymous blocksFunctionsProceduresPackagesTriggersObject typesWhat Is Java?Java is an industry-standard, object-oriented programming language. It includes the following concepts:A Java
13、Virtual Machine (JVM), which provides platform independenceAutomated storage management techniquesLanguage syntax that borrows from C and enforces strong typingOracle and JavaA PL/SQL function:CallableStatement cstmt = conn.prepareCall(? = CALL balance(?); cstmt.registerOutParameter(1, Types.FLOAT);
14、 cstmt.setInt(2, acctNo); cstmt.executeUpdate();float acctBal = cstmt.getFloat(1);FUNCTION balance (acct_id NUMBER) RETURN NUMBER ISacct_bal NUMBER;BEGIN SELECT bal INTO acct_bal FROM accts WHERE acct_no = acct_id; RETURN acct_bal;END;Calling the function with Java:What Is OCI?OCI provides for:The O
15、racle Call Interface (OCI) is how all database features are made accessible to application developers.OCI makes scalable and high-performance applications possible.Higher-level APIs and tools use OCI indirectly for database access.Other APIsJava Database Connectivity (JDBC)Pro*C/C+Pro*COBOLOracle C+ Interface (OCCI)Open Database Connectivity (ODBC)Oracle Data Provider for .NET ( )Oracle Objects for OLE (OO4O)Other APIsFull Notes PageSummaryIn this lesson, you should have learned how to: Use SQL*Plus and iSQL*Plus to access Oracle Database 10gDescribe the logical structure of tablesUse
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- T/CCOA 6-2020生湿面制品
- T/CCBD 9-2020品牌评价室内空气质量及相关产品检验检测机构
- T/CBMCA 024-2021通风系统净化消毒技术规范
- T/CAQI 51-2018家用和类似用途节水型纳滤滤芯
- T/CAPE 11001-2019基于建筑信息模型(BIM)的预制梁张拉及压浆设备施工动态监控规范
- 大厂公司面试题及答案
- 一线大厂java专家面试题及答案
- 建设能源面试题及答案
- 2025年幼儿教师实训心得体会模版
- 水务物资公司经理助理竞聘演讲稿
- GB/T 12359-2008梯形螺纹极限尺寸
- 企业统计基础工作规范化建设工作总结范文
- 安全生产物资领用登记表
- 玉雕教学讲解课件
- 国开电大农村社会学形考任务1-4答案
- 素混凝土灌注CFG桩施工技术
- DBJ51-T 198-2022 四川省既有民用建筑结构安全隐患排查技术标准
- 数控加工中心培训课件
- 2分钟双人相声剧本
- 小学数学节低年级一二年级七巧板竞赛试题
- 轮扣架支撑模板施工方案(169页)
评论
0/150
提交评论